root / trunk / install / launcher / izpack-launcher-1.3_linux / src / wx / include / wx / encconv.h @ 6834
History | View | Annotate | Download (6.13 KB)
1 |
/////////////////////////////////////////////////////////////////////////////
|
---|---|
2 |
// Name: wx/encconv.h
|
3 |
// Purpose: wxEncodingConverter class for converting between different
|
4 |
// font encodings
|
5 |
// Author: Vaclav Slavik
|
6 |
// Copyright: (c) 1999 Vaclav Slavik
|
7 |
// Licence: wxWindows Licence
|
8 |
/////////////////////////////////////////////////////////////////////////////
|
9 |
|
10 |
#ifndef _WX_ENCCONV_H_
|
11 |
#define _WX_ENCCONV_H_
|
12 |
|
13 |
#include "wx/defs.h" |
14 |
|
15 |
#if wxUSE_FONTMAP
|
16 |
|
17 |
#include "wx/object.h" |
18 |
#include "wx/fontenc.h" |
19 |
#include "wx/dynarray.h" |
20 |
|
21 |
// ----------------------------------------------------------------------------
|
22 |
// constants
|
23 |
// ----------------------------------------------------------------------------
|
24 |
|
25 |
enum
|
26 |
{ |
27 |
wxCONVERT_STRICT, |
28 |
wxCONVERT_SUBSTITUTE |
29 |
}; |
30 |
|
31 |
|
32 |
enum
|
33 |
{ |
34 |
wxPLATFORM_CURRENT = -1,
|
35 |
|
36 |
wxPLATFORM_UNIX = 0,
|
37 |
wxPLATFORM_WINDOWS, |
38 |
wxPLATFORM_OS2, |
39 |
wxPLATFORM_MAC |
40 |
}; |
41 |
|
42 |
// ----------------------------------------------------------------------------
|
43 |
// types
|
44 |
// ----------------------------------------------------------------------------
|
45 |
|
46 |
WX_DEFINE_ARRAY_INT(wxFontEncoding, wxFontEncodingArray); |
47 |
|
48 |
//--------------------------------------------------------------------------------
|
49 |
// wxEncodingConverter
|
50 |
// This class is capable of converting strings between any two
|
51 |
// 8bit encodings/charsets. It can also convert from/to Unicode
|
52 |
//--------------------------------------------------------------------------------
|
53 |
|
54 |
class WXDLLEXPORT wxEncodingConverter : public wxObject |
55 |
{ |
56 |
public:
|
57 |
|
58 |
wxEncodingConverter(); |
59 |
~wxEncodingConverter() { if (m_Table) delete[] m_Table; }
|
60 |
|
61 |
// Initialize conversion. Both output or input encoding may
|
62 |
// be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1.
|
63 |
//
|
64 |
// All subsequent calls to Convert() will interpret it's argument
|
65 |
// as a string in input_enc encoding and will output string in
|
66 |
// output_enc encoding.
|
67 |
//
|
68 |
// You must call this method before calling Convert. You may call
|
69 |
// it more than once in order to switch to another conversion
|
70 |
//
|
71 |
// Method affects behaviour of Convert() in case input character
|
72 |
// cannot be converted because it does not exist in output encoding:
|
73 |
// wxCONVERT_STRICT --
|
74 |
// follow behaviour of GNU Recode - just copy unconvertable
|
75 |
// characters to output and don't change them (it's integer
|
76 |
// value will stay the same)
|
77 |
// wxCONVERT_SUBSTITUTE --
|
78 |
// try some (lossy) substitutions - e.g. replace
|
79 |
// unconvertable latin capitals with acute by ordinary
|
80 |
// capitals, replace en-dash or em-dash by '-' etc.
|
81 |
// both modes gurantee that output string will have same length
|
82 |
// as input string
|
83 |
//
|
84 |
// Returns FALSE if given conversion is impossible, TRUE otherwise
|
85 |
// (conversion may be impossible either if you try to convert
|
86 |
// to Unicode with non-Unicode build of wxWindows or if input
|
87 |
// or output encoding is not supported.)
|
88 |
bool Init(wxFontEncoding input_enc, wxFontEncoding output_enc, int method = wxCONVERT_STRICT); |
89 |
|
90 |
// Convert input string according to settings passed to Init.
|
91 |
// Note that you must call Init before using Convert!
|
92 |
void Convert(const char* input, char* output); |
93 |
void Convert(char* str) { Convert(str, str); } |
94 |
wxString Convert(const wxString& input);
|
95 |
|
96 |
#if wxUSE_WCHAR_T
|
97 |
void Convert(const char* input, wchar_t* output); |
98 |
void Convert(const wchar_t* input, char* output); |
99 |
void Convert(const wchar_t* input, wchar_t* output); |
100 |
void Convert(wchar_t* str) { Convert(str, str); }
|
101 |
#endif
|
102 |
// Return equivalent(s) for given font that are used
|
103 |
// under given platform. wxPLATFORM_CURRENT means the plaform
|
104 |
// this binary was compiled for
|
105 |
//
|
106 |
// Examples:
|
107 |
// current platform enc returned value
|
108 |
// -----------------------------------------------------
|
109 |
// unix CP1250 {ISO8859_2}
|
110 |
// unix ISO8859_2 {}
|
111 |
// windows ISO8859_2 {CP1250}
|
112 |
//
|
113 |
// Equivalence is defined in terms of convertibility:
|
114 |
// 2 encodings are equivalent if you can convert text between
|
115 |
// then without loosing information (it may - and will - happen
|
116 |
// that you loose special chars like quotation marks or em-dashes
|
117 |
// but you shouldn't loose any diacritics and language-specific
|
118 |
// characters when converting between equivalent encodings).
|
119 |
//
|
120 |
// Convert() method is not limited to converting between
|
121 |
// equivalent encodings, it can convert between arbitrary
|
122 |
// two encodings!
|
123 |
//
|
124 |
// Remember that this function does _NOT_ check for presence of
|
125 |
// fonts in system. It only tells you what are most suitable
|
126 |
// encodings. (It usually returns only one encoding)
|
127 |
//
|
128 |
// Note that argument enc itself may be present in returned array!
|
129 |
// (so that you can -- as a side effect -- detect whether the
|
130 |
// encoding is native for this platform or not)
|
131 |
static wxFontEncodingArray GetPlatformEquivalents(wxFontEncoding enc, int platform = wxPLATFORM_CURRENT); |
132 |
|
133 |
// Similar to GetPlatformEquivalent, but this one will return ALL
|
134 |
// equivalent encodings, regardless the platform, including itself.
|
135 |
static wxFontEncodingArray GetAllEquivalents(wxFontEncoding enc);
|
136 |
|
137 |
private:
|
138 |
|
139 |
#if wxUSE_WCHAR_T
|
140 |
wchar_t *m_Table; |
141 |
#else
|
142 |
char *m_Table;
|
143 |
#endif
|
144 |
bool m_UnicodeInput, m_UnicodeOutput;
|
145 |
bool m_JustCopy;
|
146 |
|
147 |
}; |
148 |
|
149 |
#endif // wxUSE_FONTMAP |
150 |
|
151 |
#endif // _WX_ENCCONV_H_ |