Read it if you want to know more about how to write programs able to work with
characters from languages other than English.
Read it if you want to know more about how to write programs able to work with
characters from languages other than English.
on the platforms which support it. Unicode is a standard for character
encoding which addresses the shortcomings of the previous, 8 bit standards, by
using at least 16 (and possibly 32) bits for encoding each character. This
on the platforms which support it. Unicode is a standard for character
encoding which addresses the shortcomings of the previous, 8 bit standards, by
using at least 16 (and possibly 32) bits for encoding each character. This
need for the system to convert all strings the program uses to/from Unicode
each time a system call is made.
need for the system to convert all strings the program uses to/from Unicode
each time a system call is made.
many cases it is unwise to write a program which can only work in Unicode
environment. A better solution is to write programs in such way that they may
be compiled either in ANSI (traditional) mode or in the Unicode one.
many cases it is unwise to write a program which can only work in Unicode
environment. A better solution is to write programs in such way that they may
be compiled either in ANSI (traditional) mode or in the Unicode one.
And finally, the standard preprocessor tokens enumerated above expand to ANSI
strings but it is more likely that Unicode strings are wanted in the Unicode
And finally, the standard preprocessor tokens enumerated above expand to ANSI
strings but it is more likely that Unicode strings are wanted in the Unicode
and {\tt \_\_TTIME\_\_} which behave exactly as the standard ones except that
they produce ANSI strings in ANSI build and Unicode ones in the Unicode build.
and {\tt \_\_TTIME\_\_} which behave exactly as the standard ones except that
they produce ANSI strings in ANSI build and Unicode ones in the Unicode build.
\helpref{wxString}{wxstring} supports Unicode, i.e. it stores either ANSI or
Unicode strings depending on the compile mode.
\helpref{wxString}{wxstring} supports Unicode, i.e. it stores either ANSI or
Unicode strings depending on the compile mode.
-Finally, there is a special {\tt wxT()} macro which should enclose all literal
-strings in the program. As it is easy to see comparing the last fragment with
-the one above, this macro expands to nothing in the (usual) ANSI mode and
-prefixes {\tt 'L'} to its argument in the Unicode mode.
+Finally, there is a special \helpref{wxT()}{wxt} macro which should enclose all
+literal strings in the program. As it is easy to see comparing the last
+fragment with the one above, this macro expands to nothing in the (usual) ANSI
+mode and prefixes {\tt 'L'} to its argument in the Unicode mode.
The important conclusion is that if you use {\tt wxChar} instead of
{\tt char}, avoid using C style strings and use {\tt wxString} instead and
The important conclusion is that if you use {\tt wxChar} instead of
{\tt char}, avoid using C style strings and use {\tt wxString} instead and
program automatically becomes (almost) Unicode compliant!
Just let us state once again the rules:
\begin{itemize}
\item Always use {\tt wxChar} instead of {\tt char}
program automatically becomes (almost) Unicode compliant!
Just let us state once again the rules:
\begin{itemize}
\item Always use {\tt wxChar} instead of {\tt char}
-\item Always enclose literal string constants in {\tt wxT()} macro unless
-they're already converted to the right representation (another standard
-wxWindows macro {\tt \_()} does it, so there is no need for {\tt wxT()} in this
-case) or you intend to pass the constant directly to an external function
-which doesn't accept wide-character strings.
+\item Always enclose literal string constants in \helpref{wxT()}{wxt} macro
+unless they're already converted to the right representation (another standard
+wxWidgets macro \helpref{\_()}{underscore} does it, for example, so there is no
+need for {\tt wxT()} in this case) or you intend to pass the constant directly
+to an external function which doesn't accept wide-character strings.
and macros, but it has been also mentioned that it isn't quite enough.
Although everything works fine inside the program, things can get nasty when
it tries to communicate with the outside world which, sadly, often expects
ANSI strings (a notable exception is the entire Win32 API which accepts either
Unicode or ANSI strings and which thus makes it unnecessary to ever perform
and macros, but it has been also mentioned that it isn't quite enough.
Although everything works fine inside the program, things can get nasty when
it tries to communicate with the outside world which, sadly, often expects
ANSI strings (a notable exception is the entire Win32 API which accepts either
Unicode or ANSI strings and which thus makes it unnecessary to ever perform
To get a ANSI string from a wxString, you may use the
mb\_str() function which always returns an ANSI
To get a ANSI string from a wxString, you may use the
mb\_str() function which always returns an ANSI
% TODO describe fn_str(), wx_str(), wxCharBuf classes, ...
% TODO describe fn_str(), wx_str(), wxCharBuf classes, ...
-Unicode mode. Note that it currently only works in Win32 and that some parts of
-wxWindows are not Unicode-compliant yet (ODBC classes, for example). If you
+Unicode mode. Note that it currently only works in Win32 and GTK 2.0 and
+that some parts of
+wxWidgets are not Unicode-compliant yet. If you
compile your program in ANSI mode you can still define {\tt wxUSE\_WCHAR\_T}
to get some limited support for {\tt wchar\_t} type.
This will allow your program to perform conversions between Unicode strings and
compile your program in ANSI mode you can still define {\tt wxUSE\_WCHAR\_T}
to get some limited support for {\tt wchar\_t} type.
This will allow your program to perform conversions between Unicode strings and
-ANSI ones (\helpref{wxEncodingConverter}{wxencodingconverter} depends on this
-partially) and construct wxString objects from Unicode strings (presumably read
+ANSI ones (using \helpref{wxMBConv classes}{mbconvclasses})
+and construct wxString objects from Unicode strings (presumably read