Unicode

From WxWiki
Jump to: navigation, search

Official Documentation

See Unicode Support in wxWidgets.

Quick Reference

  • Always use wxChar instead of char.
  • Always enclose literal string constants in the wxT() or _T() macro (they are synonymous), except when you intend to pass the constant directly to an external function which doesn't accept wide-character strings. If you want to translate the string, use _() instead.
  • Use wxString instead of C style strings.
  • Use SQL_C_WXCHAR for wxDbTable string datatypes rather than SQL_C_CHAR.
  • To have Unicode for Windows 98/Me read about MSLU.

Pitfalls

Microsoft Visual Studio

If UNICODE or _UNICODE is defined (as it is on the command line in the Unicode configurations of the VC++ project files), then wxUSE_UNICODE gets defined automatically in wx/wxchar.h.

If you enable wxUSE_UNICODE in the original setup.h, and build all eight configurations, you're going to have eight Unicode builds instead of four ANSI and four Unicode.

Microsoft Visual Studio for Windows 98 and Windows ME

To use UNICODE on Win98/ME you need to make sure unicows.lib is included in the library dependency list first. It needs to come before all the default libraries. Also, the default libraries must come before all your wxWidget libraries. (For instance: unicows.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib comctl32.lib rpcrt4.lib wsock32.lib oleacc.lib wxmsw26u_core.lib wxbase26u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib).

You also need to download the MSLU DLL from Microsoft and include that in the application directory. (Be careful of the licensing requirements though.) See the install.txt in the wxWidgets /docs/msw directory for more infomation on MSLU and alternatives such as libunicows and opencow.

Also, you need to enable support for MSLU in wxWidgets. Read more at the MSLU wxWiki page.

See Also