37iconv_t iconv_open (
const char*,
const char*);
38size_t iconv (iconv_t,
char**,
size_t*,
char**,
size_t*);
39int iconv_close (iconv_t);
42iconv_t iconv_open (
const char *from_code,
const char *to_code)
49 { 437,
"OEM - United States" },
50 { 500,
"IBM EBCDIC - International" },
51 { 708,
"Arabic - ASMO 708" },
52 { 709,
"Arabic - ASMO 449+, BCON V4" },
53 { 710,
"Arabic - Transparent Arabic" },
54 { 720,
"Arabic - Transparent ASMO" },
55 { 737,
"OEM - Greek (formerly 437G)" },
56 { 775,
"OEM - Baltic" },
57 { 850,
"OEM - Multilingual Latin I" },
58 { 852,
"OEM - Latin II" },
59 { 855,
"OEM - Cyrillic (primarily Russian)" },
60 { 857,
"OEM - Turkish" },
61 { 858,
"OEM - Multlingual Latin I + Euro symbol" },
62 { 860,
"OEM - Portuguese" },
63 { 861,
"OEM - Icelandic" },
64 { 862,
"OEM - Hebrew" },
65 { 863,
"OEM - Canadian-French" },
66 { 864,
"OEM - Arabic" },
67 { 865,
"OEM - Nordic" },
68 { 866,
"OEM - Russian" },
69 { 869,
"OEM - Modern Greek" },
70 { 870,
"IBM EBCDIC - Multilingual/ROECE (Latin-2)" },
71 { 874,
"ANSI/OEM - Thai (same as 28605, ISO 8859-15)" },
72 { 875,
"IBM EBCDIC - Modern Greek" },
74 { 936,
"ANSI/OEM - Simplified Chinese (PRC, Singapore)" },
75 { 949,
"ANSI/OEM - Korean (Unified Hangeul Code)" },
76 { 950,
"ANSI/OEM - Traditional Chinese" },
77 { 1026,
"IBM EBCDIC - Turkish (Latin-5)" },
78 { 1047,
"IBM EBCDIC - Latin 1/Open System" },
79 { 1140,
"EBCDIC-CA-FR@EURO" },
80 { 1141,
"EBCDIC-AT-DE@EURO" },
81 { 1142,
"EBCDIC-DK-NO@EURO" },
82 { 1143,
"EBCDIC-FI-SE@EURO" },
83 { 1144,
"EBCDIC-IT@EURO" },
84 { 1145,
"EBCDIC-ES-A@EURO" },
85 { 1146,
"EBCDIC-UK@EURO" },
86 { 1147,
"EBCDIC-FR@EURO" },
87 { 1148,
"IBM EBCDIC - International (500 + Euro symbol)" },
88 { 1149,
"EBCDIC-IS-FRISS@EURO" },
91 { 1251,
"ANSI - Cyrillic" },
92 { 1252,
"ANSI - Latin I" },
93 { 1253,
"ANSI - Greek" },
94 { 1254,
"ANSI - Turkish" },
95 { 1255,
"ANSI - Hebrew" },
96 { 1256,
"ANSI - Arabic" },
97 { 1257,
"ANSI - Baltic" },
98 { 1258,
"ANSI/OEM - Vietnamese" },
99 { 1361,
"Korean (Johab)" },
100 { 10000,
"MAC - Roman" },
102 { 10002,
"MAC - Traditional Chinese (Big5)" },
105 { 10005,
"MAC - Hebrew" },
106 { 10006,
"MAC - Greek I" },
107 { 10007,
"MAC-CYRILLIC" },
108 { 10008,
"MAC - Simplified Chinese (GB 2312)" },
109 { 10010,
"MAC - Romania" },
110 { 10017,
"MAC - Ukraine" },
111 { 10021,
"MAC - Thai" },
112 { 10029,
"MAC - Latin II" },
113 { 10079,
"MAC - Icelandic" },
114 { 10081,
"MAC - Turkish" },
115 { 10082,
"MAC - Croatia" },
116 { 12000,
"UCS-4-LE" },
117 { 12001,
"UCS-4-BE" },
118 { 20000,
"CNS - Taiwan" },
119 { 20001,
"TCA - Taiwan" },
120 { 20002,
"Eten - Taiwan" },
121 { 20003,
"IBM5550 - Taiwan" },
122 { 20004,
"TeleText - Taiwan" },
123 { 20005,
"Wang - Taiwan" },
124 { 20105,
"IA5 IRV International Alphabet No. 5 (7-bit)" },
125 { 20106,
"IA5 German (7-bit)" },
126 { 20107,
"IA5 Swedish (7-bit)" },
127 { 20108,
"IA5 Norwegian (7-bit)" },
128 { 20127,
"ANSI_X3.4-1968" },
130 { 20269,
"ISO 6937 Non-Spacing Accent" },
131 { 20273,
"EBCDIC-DE" },
132 { 20277,
"EBCDIC-DK-NO" },
133 { 20278,
"EBCDIC-FI-SE" },
134 { 20280,
"EBCDIC-IT" },
135 { 20284,
"EBCDIC-ES-A" },
136 { 20285,
"EBCDIC-UK" },
137 { 20290,
"EBCDIC-JP" },
138 { 20297,
"EBCDIC-FR" },
139 { 20420,
"EBCDIC-AR" },
140 { 20423,
"IBM EBCDIC - Greek" },
141 { 20424,
"IBM EBCDIC - Hebrew" },
142 { 20833,
"EBCDIC-KR" },
143 { 20838,
"IBM EBCDIC - Thai" },
144 { 20866,
"Russian - KOI8-R" },
145 { 20871,
"IBM EBCDIC - Icelandic" },
146 { 20880,
"IBM EBCDIC - Cyrillic (Russian)" },
147 { 20905,
"IBM EBCDIC - Turkish" },
148 { 20924,
"IBM EBCDIC - Latin-1/Open System (1047 + Euro symbol)" },
149 { 20932,
"JIS X 0208-1990 & 0121-1990" },
151 { 21025,
"IBM EBCDIC - Cyrillic (Serbian, Bulgarian)" },
152 { 21027,
"Extended Alpha Lowercase" },
153 { 21866,
"Ukrainian (KOI8-U)" },
154 { 28591,
"ISO-8859-1" },
155 { 28592,
"ISO-8859-2" },
156 { 28593,
"ISO-8859-3" },
157 { 28594,
"ISO-8859-4" },
158 { 28595,
"ISO-8859-5" },
159 { 28596,
"ISO-8859-6" },
160 { 28597,
"ISO-8859-7" },
161 { 28598,
"ISO-8859-8" },
162 { 28599,
"ISO-8859-95" },
163 { 28605,
"ISO-8859-15" },
164 { 29001,
"Europa 3" },
165 { 38598,
"ISO-8859-8 Hebrew" },
166 { 50220,
"ISO-2022 Japanese with no halfwidth Katakana" },
167 { 50221,
"ISO-2022-JP" },
168 { 50222,
"ISO-2022 Japanese JIS X 0201-1989" },
169 { 50225,
"ISO-2022-KR" },
170 { 50227,
"ISO-2022 Simplified Chinese" },
171 { 50229,
"ISO-2022 Traditional Chinese" },
172 { 50930,
"Japanese (Katakana) Extended" },
173 { 50931,
"US/Canada and Japanese" },
174 { 50933,
"Korean Extended and Korean" },
175 { 50935,
"Simplified Chinese Extended and Simplified Chinese" },
176 { 50936,
"Simplified Chinese" },
177 { 50937,
"US/Canada and Traditional Chinese" },
178 { 50939,
"Japanese (Latin) Extended and Japanese" },
180 { 51936,
"EUC - Simplified Chinese" },
182 { 51950,
"EUC - Traditional Chinese" },
183 { 52936,
"HZ-GB2312 Simplified Chinese" },
184 { 54936,
"Windows XP: GB18030 Simplified Chinese (4 Byte)" },
185 { 57002,
"ISCII Devanagari 57003 ISCII Bengali" },
186 { 57004,
"ISCII Tamil" },
187 { 57005,
"ISCII Telugu" },
188 { 57006,
"ISCII Assamese" },
189 { 57007,
"ISCII Oriya" },
190 { 57008,
"ISCII Kannada" },
191 { 57009,
"ISCII Malayalam" },
192 { 57010,
"ISCII Gujarati" },
193 { 57011,
"ISCII Punjabi" },
200 for (
size_t i = 0; ; ++
i) {
202 if (
i ==
sizeof pages /
sizeof *pages) {
207 if (!strcmp (from_code, pages [
i].
name)) {
208 cd |= pages [
i].code << 16;
214 if (!strcmp (to_code, pages [
i].
name)) {
215 cd |= pages [
i].code & 0xffff;
224 || !MultiByteToWideChar (cd & 0x0000ffff, 0,
"", 1, 0, 0)
225 || !MultiByteToWideChar ((cd >> 16) & 0x0000ffff, 0,
"", 1, 0, 0)) {
237size_t iconv (iconv_t cd,
238 char **inbuf,
size_t *inbytesleft,
239 char **outbuf,
size_t *outbytesleft)
241 const int fromcode = (cd >> 16) & 0x0000ffff;
242 const int tocode = cd & 0x0000ffff;
244 if (0x0000ffff == fromcode || 0x0000ffff == tocode) {
254 wchar_t *pwc = *inbytesleft <
sizeof wbuf /
sizeof *wbuf ?
255 wbuf :
new wchar_t [*inbytesleft];
260 MultiByteToWideChar (fromcode, MB_ERR_INVALID_CHARS,
261 *inbuf,
int (*inbytesleft),
262 pwc,
int (*inbytesleft));
268 const int error = GetLastError ();
278 WideCharToMultiByte (tocode, 0,
280 *outbuf,
int (*outbytesleft),
282 if (!nnout || !*outbytesleft) {
286 const int error = GetLastError ();
295 MultiByteToWideChar (tocode, 0, *outbuf, nnout, 0, 0);
301 const int error = GetLastError ();
311 WideCharToMultiByte (fromcode, 0, pwc, nwin, 0, 0, 0, 0);
316 const int error = GetLastError ();
326 *inbytesleft -= nnin;
327 *outbytesleft -= nnout;
338int iconv_close (iconv_t cd)
340 const int fromcode = (cd >> 16) & 0x0000ffff;
341 const int tocode = cd & 0x0000ffff;
343 if (0x0000ffff == fromcode || 0x0000ffff == tocode) {
@ error
throw a parse_error exception in case of a tag