
                              Wine Documentation                               
Prev                     Chapter 2. Portability issues                     Next
-------------------------------------------------------------------------------

Unicode

Because gcc and glibc use 4 byte unicode characters, the compiler intrinsic
L"foo" generates unicode strings which cannot be used by Winelib (Win32 code
expects 16 bit unicode characters). There are 3 workarounds for this:

 1. Use the latest gcc version (2.9.7 or later), and pass the -fshort-wchar
    option to every file that is built.
   
 2. Use the __TEXT("foo") macro, define WINE_UNICODE_REWRITE for each file that
    is built, and add -fwritable-strings to the compiler command line. You
    should replace all occurances of wchar_t with WCHAR also, since wchar_t is
    the native (32 bit) type. These changes allow Wine to modify the native
    unicode strings created by the compiler in place, so that they are 16 bit
    by the time any functions get to use them. This scheme works with older
    versions of gcc (2.95.x+).
   
 3. Use the compiler default, but don't call any Win32 unicode functions without
    converting the strings first!
   

If you are using Unicode and you want to be able to use standard library calls
(e.g. wcslen, wsprintf) as well as Win32 unicode calls (API functions ending in
W, or having _UNICODE defined), then you should use the msvcrt runtime library
instead of glibc. The functions in glibc will not work correctly with 16 bit
strings.

If you need a Unicode string even when _UNICODE isn't defined, use
WINE_UNICODE_TEXT("foo"). This will need to be wrapped in #ifdef WINELIB to
prevent breaking your source for windows compiles.

To prevent warnings when declaring a single unicode character in C, use (WCHAR)
L'x', rather than __TEXT('x'). This works on Windows also.
-------------------------------------------------------------------------------
Prev                                  Home                                 Next
Portability issues                     Up                             C library
