%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: tmbconv.tex
-%% Purpose: Overview of the wxMBConv classes in wxWindows
+%% Purpose: Overview of the wxMBConv classes in wxWidgets
%% Author: Ove Kaaven
%% Modified by:
%% Created: 25.03.00
%% RCS-ID: $Id$
%% Copyright: (c) 2000 Ove Kaaven
-%% Licence: wxWindows license
+%% Licence: wxWidgets license
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{wxMBConv classes overview}\label{mbconvclasses}
-Classes: \helpref{wxMBConv}{wxmbconv}, \helpref{wxMBConvFile}{wxmbconvfile},
+Classes: \helpref{wxMBConv}{wxmbconv}, wxMBConvLibc,
\helpref{wxMBConvUTF7}{wxmbconvutf7}, \helpref{wxMBConvUTF8}{wxmbconvutf8},
-\helpref{wxCSConv}{wxcsconv}
+\helpref{wxCSConv}{wxcsconv},
+\helpref{wxMBConvUTF16}{wxmbconvutf16}, \helpref{wxMBConvUTF32}{wxmbconvutf32}
-The wxMBConv classes in wxWindows enables an Unicode-aware application to
+The wxMBConv classes in wxWidgets enables an Unicode-aware application to
easily convert between Unicode and the variety of 8-bit encoding systems still
in use.
\subsection{Background: The wxString class}
-If you have compiled wxWindows in Unicode mode, the wxChar type will become
+If you have compiled wxWidgets in Unicode mode, the wxChar type will become
identical to wchar\_t rather than char, and a wxString stores wxChars. Hence,
all wxString manipulation in your application will then operate on Unicode
strings, and almost as easily as working with ordinary char strings (you
The base class for all these conversions is the wxMBConv class (which itself
implements standard libc locale conversion). Derived classes include
-wxMBConvFile, wxMBConvUTF7, wxMBConvUTF8, and wxCSConv, which implement
-different kinds of conversions. You can also derive your own class for your
-own custom encoding and use it, should you need it. All you need to do is
-override the MB2WC and WC2MB methods.
+wxMBConvLibc, several different wxMBConvUTFxxx classes, and wxCSConv, which
+implement different kinds of conversions. You can also derive your own class
+for your own custom encoding and use it, should you need it. All you need to do
+is override the MB2WC and WC2MB methods.
\subsection{wxMBConv objects}
-In C++, for a class to be useful and possible to pass around, it needs to be
-instantiated. All of the wxWindows-provided wxMBConv classes have predefined
-instances (wxConvLibc, wxConvFile, wxConvUTF7, wxConvUTF8, wxConvLocal).
-You can use these predefined objects directly, or you can instantiate your own
-objects.
+Several of the wxWidgets-provided wxMBConv classes have predefined instances
+(wxConvLibc, wxConvFile, wxConvUTF7, wxConvUTF8, wxConvLocal). You can use
+these predefined objects directly, or you can instantiate your own objects.
-A variable, wxConvCurrent, points to the conversion object that the user interface
-is supposed to use, in the case that the user interface is not Unicode-based (like
-with GTK+ 1.2). By default, it points to wxConvLibc or wxConvLocal, depending on
-which works best on the current platform.
+A variable, wxConvCurrent, points to the conversion object that the user
+interface is supposed to use, in the case that the user interface is not
+Unicode-based (like with GTK+ 1.2). By default, it points to wxConvLibc or
+wxConvLocal, depending on which works best on the current platform.
\subsection{wxCSConv}
Once you have chosen which object you want to use to convert your text,
here is how you would use them with wxString. These examples all assume
-that you are using a Unicode build of wxWindows, although they will still
+that you are using a Unicode build of wxWidgets, although they will still
compile in a non-Unicode build (they just won't convert anything).
Example 1: Constructing a wxString from input in current encoding.
printf("Data: %s\n", (const char*) str.mb_str(cust));
\end{verbatim}
-Note: Since mb_str() returns a temporary wxCharBuffer to hold the result
+Note: Since mb\_str() returns a temporary wxCharBuffer to hold the result
of the conversion, you need to explicitly cast it to const char* if you use
it in a vararg context (like with printf).
If you have specialized needs, or just don't want to use wxString, you
can also use the conversion methods of the conversion objects directly.
This can even be useful if you need to do conversion in a non-Unicode
-build of wxWindows; converting a string from UTF-8 to the current
+build of wxWidgets; converting a string from UTF-8 to the current
encoding should be possible by doing this:
\begin{verbatim}
Here, cMB2WC of the UTF8 object returns a wxWCharBuffer containing a Unicode
string. The wxString constructor then converts it back to an 8-bit character
set using the passed conversion object, *wxConvCurrent. (In a Unicode build
-of wxWindows, the constructor ignores the passed conversion object and
+of wxWidgets, the constructor ignores the passed conversion object and
retains the Unicode data.)
This could also be done by first making a wxString of the original data:
\end{verbatim}
If a conversion had taken place in cWX2MB (i.e. in a Unicode build),
-the buffer will be deallocated as soon as tmp_buf goes out of scope.
+the buffer will be deallocated as soon as tmp\_buf goes out of scope.
(The macro wxWX2MBbuf reflects the correct return value of cWX2MB
(either char* or wxCharBuffer), except for the const.)