]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/encconv.tex
added and documented wxDEFINE_SCOPED_PTR_TYPE; improved docs a bit
[wxWidgets.git] / docs / latex / wx / encconv.tex
CommitLineData
c958260b
VS
1%
2% automatically generated by HelpGen from
3% encconv.h at 30/Dec/99 18:45:16
4%
5
c958260b
VS
6\section{\class{wxEncodingConverter}}\label{wxencodingconverter}
7
a663cce7 8This class is capable of converting strings between two
457e6c54 98-bit encodings/charsets. It can also convert from/to Unicode (but only
a663cce7
VS
10if you compiled wxWindows with wxUSE\_WCHAR\_T set to 1). Only limited subset
11of encodings in supported by wxEncodingConverter:
12{\tt wxFONTENCODING\_ISO8859\_1..15}, {\tt wxFONTENCODING\_CP1250..1257} and
13{\tt wxFONTENCODING\_KOI8}.
14
15\wxheading{Note}
16
17Please use \helpref{wxMBConv classes}{mbconvclasses} instead
18if possible. \helpref{wxCSConv}{wxcsconv} has much better support for various
19encodings than wxEncodingConverter. wxEncodingConverter is useful only
20if you rely on {\tt wxCONVERT\_SUBSTITUTE} mode of operation (see
21\helpref{Init}{wxencodingconverterinit}).
c958260b 22
c958260b
VS
23\wxheading{Derived from}
24
25\helpref{wxObject}{wxobject}
26
9704b250
VS
27\wxheading{Include files}
28
29<wx/encconv.h>
30
04a4a2af
VS
31\wxheading{See also}
32
33\helpref{wxFontMapper}{wxfontmapper},
f6bcfd97 34\helpref{wxMBConv}{wxmbconv},
04a4a2af
VS
35\helpref{Writing non-English applications}{nonenglishoverview}
36
37
c958260b
VS
38\latexignore{\rtfignore{\wxheading{Members}}}
39
c958260b
VS
40\membersection{wxEncodingConverter::wxEncodingConverter}\label{wxencodingconverterwxencodingconverter}
41
42\func{}{wxEncodingConverter}{\void}
43
44Constructor.
45
46\membersection{wxEncodingConverter::Init}\label{wxencodingconverterinit}
47
48\func{bool}{Init}{\param{wxFontEncoding }{input\_enc}, \param{wxFontEncoding }{output\_enc}, \param{int }{method = wxCONVERT\_STRICT}}
49
2edb0bde 50Initialize conversion. Both output or input encoding may
c958260b
VS
51be wxFONTENCODING\_UNICODE, but only if wxUSE\_ENCODING is set to 1.
52All subsequent calls to \helpref{Convert()}{wxencodingconverterconvert}
457e6c54
JS
53will interpret its argument
54as a string in {\it input\_enc} encoding and will output string in
c958260b
VS
55{\it output\_enc} encoding.
56You must call this method before calling Convert. You may call
57it more than once in order to switch to another conversion.
58{\it Method} affects behaviour of Convert() in case input character
59cannot be converted because it does not exist in output encoding:
60
457e6c54 61\begin{twocollist}\itemsep=0pt
c958260b 62\twocolitem{{\bf wxCONVERT\_STRICT}}{follow behaviour of GNU Recode -
f6bcfd97 63just copy unconvertible characters to output and don't change them
c958260b
VS
64(its integer value will stay the same)}
65\twocolitem{{\bf wxCONVERT\_SUBSTITUTE}}{try some (lossy) substitutions
f6bcfd97 66- e.g. replace unconvertible latin capitals with acute by ordinary
c958260b
VS
67capitals, replace en-dash or em-dash by '-' etc.}
68\end{twocollist}
69
f6bcfd97 70Both modes guarantee that output string will have same length
c958260b
VS
71as input string.
72
73\wxheading{Return value}
74
cc81d32f 75false if given conversion is impossible, true otherwise
c958260b
VS
76(conversion may be impossible either if you try to convert
77to Unicode with non-Unicode build of wxWindows or if input
78or output encoding is not supported.)
79
c958260b
VS
80\membersection{wxEncodingConverter::Convert}\label{wxencodingconverterconvert}
81
7a766dcd
VS
82\func{void}{Convert}{\param{const char* }{input}, \param{char* }{output}}
83
84\func{void}{Convert}{\param{const wchar\_t* }{input}, \param{wchar\_t* }{output}}
85
86\func{void}{Convert}{\param{const char* }{input}, \param{wchar\_t* }{output}}
87
88\func{void}{Convert}{\param{const wchar\_t* }{input}, \param{char* }{output}}
89
90Convert input string according to settings passed to
91\helpref{Init}{wxencodingconverterinit} and writes the result to {\it output}.
92
93\func{void}{Convert}{\param{char* }{str}}
94
95\func{void}{Convert}{\param{wchar\_t* }{str}}
96
97Convert input string according to settings passed to
98\helpref{Init}{wxencodingconverterinit} in-place, i.e. write the result to the
99same memory area.
100
c958260b
VS
101\func{wxString}{Convert}{\param{const wxString\& }{input}}
102
7a766dcd 103Convert wxString and return new wxString object.
c958260b 104
7a766dcd 105\wxheading{Notes}
c958260b 106
7a766dcd 107You must call \helpref{Init}{wxencodingconverterinit} before using this method!
5b5d025c 108
7a766dcd
VS
109{\tt wchar\_t} versions of the method are not available if wxWindows was compiled
110with {\tt wxUSE\_WCHAR\_T} set to 0.
c958260b 111
c958260b
VS
112\membersection{wxEncodingConverter::GetPlatformEquivalents}\label{wxencodingconvertergetplatformequivalents}
113
5b5d025c 114\func{static wxFontEncodingArray}{GetPlatformEquivalents}{\param{wxFontEncoding }{enc}, \param{int }{platform = wxPLATFORM\_CURRENT}}
c958260b
VS
115
116Return equivalents for given font that are used
117under given platform. Supported platforms:
118
457e6c54 119\begin{itemize}\itemsep=0pt
c958260b
VS
120\item wxPLATFORM\_UNIX
121\item wxPLATFORM\_WINDOWS
122\item wxPLATFORM\_OS2
123\item wxPLATFORM\_MAC
124\item wxPLATFORM\_CURRENT
125\end{itemize}
126
2edb0bde 127wxPLATFORM\_CURRENT means the platform this binary was compiled for.
c958260b
VS
128
129Examples:
457e6c54 130
c958260b
VS
131\begin{verbatim}
132current platform enc returned value
133----------------------------------------------
134unix CP1250 {ISO8859_2}
135unix ISO8859_2 {ISO8859_2}
136windows ISO8859_2 {CP1250}
137unix CP1252 {ISO8859_1,ISO8859_15}
138\end{verbatim}
139
140Equivalence is defined in terms of convertibility:
f6bcfd97
BP
141two encodings are equivalent if you can convert text between
142then without losing information (it may - and will - happen
143that you lose special chars like quotation marks or em-dashes
144but you shouldn't lose any diacritics and language-specific
c958260b
VS
145characters when converting between equivalent encodings).
146
147Remember that this function does {\bf NOT} check for presence of
148fonts in system. It only tells you what are most suitable
149encodings. (It usually returns only one encoding.)
150
151\wxheading{Notes}
152
457e6c54
JS
153\begin{itemize}\itemsep=0pt
154\item Note that argument {\it enc} itself may be present in the returned array,
f6bcfd97 155so that you can, as a side-effect, detect whether the
457e6c54 156encoding is native for this platform or not.
f6bcfd97
BP
157\item \helpref{Convert}{wxencodingconverterconvert} is not limited to
158converting between equivalent encodings, it can convert between two arbitrary
159encodings.
160\item If {\it enc} is present in the returned array, then it is {\bf always} the first
5b5d025c 161item of it.
f6bcfd97 162\item Please note that the returned array may contain no items at all.
c958260b
VS
163\end{itemize}
164
c958260b
VS
165\membersection{wxEncodingConverter::GetAllEquivalents}\label{wxencodingconvertergetallequivalents}
166
5b5d025c 167\func{static wxFontEncodingArray}{GetAllEquivalents}{\param{wxFontEncoding }{enc}}
c958260b
VS
168
169Similar to
170\helpref{GetPlatformEquivalents}{wxencodingconvertergetplatformequivalents},
171but this one will return ALL
f6bcfd97 172equivalent encodings, regardless of the platform, and including itself.
c958260b 173
5b5d025c
VS
174This platform's encodings are before others in the array. And again, if {\it enc} is in the array,
175it is the very first item in it.
457e6c54 176