Changeset 212e14679598106ddb6f7e305835b33a3da0adbb

Show
Ignore:
Timestamp:
03/21/06 16:39:43 (2 years ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1142955583 +0000
git-parent:

[51501a62b74ecec551f2ddd4fd7a828c7a408ed1]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1142955583 +0000
Message:

A bit explanation of the wxWidgets string conversion mess won't harm

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/gui/wxwidgets/wxwidgets.hpp

    r4613b81 r212e146  
    7070 ***************************************************************************/ 
    7171 
    72 /* wxU is used to convert ansi/utf8 strings to unicode strings (wchar_t) */ 
    73 #if defined( ENABLE_NLS ) 
     72/* 
     73 * wxU() is used to convert UTF-8 strings (typically from gettext) 
     74 * to unicode strings (wchar_t). 
     75 */ 
    7476#if wxUSE_UNICODE 
    7577#   define wxU(utf8) wxString(utf8, wxConvUTF8) 
     
    7779#   define wxU(utf8) wxString(wxConvUTF8.cMB2WC(utf8), *wxConvCurrent) 
    7880#endif 
    79 #else // ENABLE_NLS 
     81 
     82/* 
     83 * wxL2U() use to convert localized “data” strings (while wxU() would convert 
     84 * strings from gettext messages). Nowadays, the core use UTF-8 internally 
     85 * and wxL2U() is only an obsoloted name for wxU(). 
     86 */ 
     87#define wxL2U(utf8) wxU(utf8) 
     88 
    8089#if wxUSE_UNICODE 
    81 #   define wxU(ansi) wxString(ansi, wxConvLocal) 
    82 #else 
    83 #   define wxU(ansi) (ansi) 
    84 #endif 
    85 #endif 
    86  
    87 /* wxL2U (locale to unicode) is used to convert ansi strings to unicode 
    88  * strings (wchar_t) */ 
    89 #define wxL2U(ansi) wxU(ansi) 
    90  
    91 #if wxUSE_UNICODE 
     90/* 
     91 * Whoops, we assume that wchar_t is 32-bits and wide character encoding is 
     92 * UTF-32 (ok, both assumptions should de identical). This is not true on all 
     93 * platforms. 
     94 * 
     95 * On Windows, and possibly some other operating systems wchar_t is 16-bits, 
     96 * which means code points outside the Basic Multilingual Plane are encoded 
     97 * with surrogates as two subsequent wchar_t. 
     98 */ 
     99#   ifdef WIN32 
     100/* 
     101 * Removing this #error without fixing the underlying problem is stricly 
     102 * FORBIDDEN. It would result in a _really_ completely unusable wxWidgets 
     103 * interface: all string operations would fail. 
     104 * 
     105 * Corrolary: Think twice, if not more, before you compile wxWidgets with 
     106 * Unicode on Windows. 
     107 */ 
     108#       error FIXME: this is not **REALLY** going to work at all. 
     109#   endif 
    92110#   define wxFromLocale(wxstring) FromUTF32(wxstring.wc_str()) 
    93111#   define wxLocaleFree(string) free(string)