Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Unicode conversion (attention all devs)

<< < (21/23) > >>

zieQ:
Help, unicode men have modified the parsing of MSVC  :lol:

For example this line:

--- Code: ---if (line.StartsWith(_T("Project_Dep_Name"))) {
--- End code ---

Does _T means that we do nothing to the string (i.e. keep a char* representation, no unicode conversion)? I'm quite lost with _X() macros, can someone sum up them?

mandrav:

--- Quote from: zieQ on August 23, 2005, 09:46:32 am ---Help, unicode men have modified the parsing of MSVC  :lol:

For example this line:

--- Code: ---if (line.StartsWith(_T("Project_Dep_Name"))) {
--- End code ---

Does _T means that we do nothing to the string (i.e. keep a char* representation, no unicode conversion)? I'm quite lost with _X() macros, can someone sum up them?

--- End quote ---

wxT(), _T(): unicode string, not-translatable (IIRC just puts L before the quote, i.e. L"text")
_(): unicode string, translatable (use it for english messages and stuff)

There are also some conversion macros in sdk/settings.h:
_U(), _UU(), _C(), _CC()
for the conversion between char* and unicode.

Yiannis.

takeshimiya:
About char*, that's why I suggested to use byte* as typedef.

It will make clear that you are using a byte buffer instead of a character string.

char typedefed as byte or wxByte would be good.

tiwag:
from sdk/settings.h
--- Code: ---#if wxUSE_UNICODE
    #define _UU(x,y) wxString((x),(y))
    #define _CC(x,y) (x).mb_str((y))
#else
    #define _UU(x,y) (x)
    #define _CC(x,y) (x)
#endif

#define _U(x) _UU((x),wxConvUTF8)
#define _C(x) _CC((x),wxConvUTF8)
--- End code ---


from wxWidgets-Help
--- Code: -----------------------------------------------------------------------------------

wxT
wxChar wxT(char ch)

const wxChar * wxT(const char *s)

wxT() is a macro which can be used with character and string literals (in other words, 'x' or "foo") to automatically convert them to Unicode in Unicode build configuration. Please see the Unicode overview for more information.

This macro is simply returns the value passed to it without changes in ASCII build. In fact, its definition is:

#ifdef UNICODE
#define wxT(x) L ## x
#else // !Unicode
#define wxT(x) x
#endif

--------------------------------------------------------------------------------

_
const wxChar * _(const char *s)

This macro expands into a call to wxGetTranslation function, so it marks the message for the extraction by xgettext just as wxTRANSLATE does, but also returns the translation of the string for the current locale during execution.

Don't confuse this macro with _T()!



--------------------------------------------------------------------------------

wxPLURAL
const wxChar * wxPLURAL(const char *sing, const char *plur, size_tn)

This macro is identical to _() but for the plural variant of wxGetTranslation.



--------------------------------------------------------------------------------

_T
wxChar _T(char ch)

const wxChar * _T(const wxChar ch)

This macro is exactly the same as wxT and is defined in wxWidgets simply because it may be more intuitive for Windows programmers as the standard Win32 headers also define it (as well as yet another name for the same macro which is _TEXT()).

Don't confuse this macro with _()!

--------------------------------------------------------------------------------
--- End code ---


summary     (please someone might correct if i'm wrong or add missing points)


--- Code: ---_()
--- End code ---
- text's which might be translated to other user-languages

--- Code: ---_T()
wxT()
--- End code ---
- fixed text's - like XRC resources object names


--- Code: ---_U()
--- End code ---
- conversion from char* to wxString


--- Code: ---_C()
--- End code ---
- multibyte C string  see wxhelp (wxMBConv classes overview)


HTH

tiwag:

--- Quote from: takeshimiya on August 23, 2005, 10:13:37 am ---..char typedefed as byte or wxByte would be good.

--- End quote ---

i always used  "byte"  as typedef'ed  "unsigned char"

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version