4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2003,2004 Mike McCormack
6 * Copyright 2004 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
40 #include "wine/unicode.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(mlang);
47 #define CP_UNICODE 1200
49 #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
51 static HRESULT MultiLanguage_create(IUnknown *pUnkOuter, LPVOID *ppObj);
54 * Under what circumstances HKEY_CLASSES_ROOT\MIME\Database\Codepage and
55 * HKEY_CLASSES_ROOT\MIME\Database\Charset are used?
60 const char *description;
63 const char *web_charset;
64 const char *header_charset;
65 const char *body_charset;
68 /* These data are based on the codepage info in libs/unicode/cpmap.pl */
69 /* FIXME: Add 28604 (Celtic), 28606 (Balkan) */
71 static const MIME_CP_INFO arabic_cp[] =
74 864, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
75 MIMECONTF_MIME_LATEST,
76 "ibm864", "ibm864", "ibm864" },
78 1006, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
79 MIMECONTF_MIME_LATEST,
80 "ibm1006", "ibm1006", "ibm1006" },
82 1256, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
83 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
84 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
85 "windows-1256", "windows-1256", "windows-1256" },
87 28596, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
88 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
89 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
90 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
91 "iso-8859-6", "iso-8859-6", "iso-8859-6" }
93 static const MIME_CP_INFO baltic_cp[] =
96 775, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
97 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
98 "ibm775", "ibm775", "ibm775" },
100 1257, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
101 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
102 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
103 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
104 "windows-1257", "windows-1257", "windows-1257" },
106 28594, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
107 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
108 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
109 MIMECONTF_MIME_LATEST,
110 "iso-8859-4", "iso-8859-4", "iso-8859-4" },
112 28603, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
113 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
114 "iso-8859-13", "iso-8859-13", "iso-8859-13" }
116 static const MIME_CP_INFO chinese_simplified_cp[] =
118 { "Chinese Simplified (GB2312)",
119 936, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
120 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
121 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
122 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
123 "gb2312", "gb2312", "gb2312" }
125 static const MIME_CP_INFO chinese_traditional_cp[] =
127 { "Chinese Traditional (Big5)",
128 950, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
129 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
130 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
131 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
132 "big5", "big5", "big5" }
134 static const MIME_CP_INFO central_european_cp[] =
136 { "Central European (DOS)",
137 852, MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_BROWSER |
138 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
139 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
140 "ibm852", "ibm852", "ibm852" },
141 { "Central European (Windows)",
142 1250, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
143 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
144 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
145 MIMECONTF_MIME_LATEST,
146 "windows-1250", "windows-1250", "windows-1250" },
147 { "Central European (Mac)",
148 10029, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
149 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
150 "x-mac-ce", "x-mac-ce", "x-mac-ce" },
151 { "Central European (ISO)",
152 28592, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
153 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
154 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
155 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
156 "iso-8859-2", "iso-8859-2", "iso-8859-2" }
158 static const MIME_CP_INFO cyrillic_cp[] =
161 855, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
162 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
163 "ibm855", "ibm855", "ibm855" },
165 866, MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_BROWSER |
166 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
167 MIMECONTF_MIME_LATEST,
168 "cp866", "cp866", "cp866" },
169 #if 0 /* Windows has 20866 as an official code page for KOI8-R */
170 { "Cyrillic (KOI8-R)",
171 878, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
172 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
173 "koi8-r", "koi8-r", "koi8-r" },
175 { "Cyrillic (Windows)",
176 1251, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
177 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
178 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
179 "windows-1251", "windows-1251", "windows-1251" },
181 10007, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
182 MIMECONTF_MIME_LATEST,
183 "x-mac-cyrillic", "x-mac-cyrillic", "x-mac-cyrillic" },
184 { "Cyrillic (KOI8-R)",
185 20866, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
186 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
187 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
188 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
189 "koi8-r", "koi8-r", "koi8-r" },
190 { "Cyrillic (KOI8-U)",
191 21866, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
192 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
193 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
194 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
195 "koi8-u", "koi8-u", "koi8-u" },
197 28595, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
198 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
199 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
200 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
201 "iso-8859-5", "iso-8859-5", "iso-8859-5" }
203 static const MIME_CP_INFO greek_cp[] =
206 737, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
207 MIMECONTF_MIME_LATEST,
208 "ibm737", "ibm737", "ibm737" },
209 { "Greek, Modern (DOS)",
210 869, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
211 MIMECONTF_MIME_LATEST,
212 "ibm869", "ibm869", "ibm869" },
213 { "IBM EBCDIC (Greek Modern)",
214 875, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
215 MIMECONTF_MIME_LATEST,
216 "cp875", "cp875", "cp875" },
218 1253, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
219 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
220 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
221 "windows-1253", "windows-1253", "windows-1253" },
223 10006, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
224 MIMECONTF_MIME_LATEST,
225 "x-mac-greek", "x-mac-greek", "x-mac-greek" },
227 28597, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
228 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
229 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
230 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
231 "iso-8859-7", "iso-8859-7", "iso-8859-7" }
233 static const MIME_CP_INFO hebrew_cp[] =
236 424, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
237 MIMECONTF_MIME_LATEST,
238 "ibm424", "ibm424", "ibm424" },
240 856, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
241 MIMECONTF_MIME_LATEST,
242 "cp856", "cp856", "cp856" },
244 862, MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
245 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
246 MIMECONTF_MIME_LATEST,
247 "dos-862", "dos-862", "dos-862" },
248 { "Hebrew (Windows)",
249 1255, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
250 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
251 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
252 "windows-1255", "windows-1255", "windows-1255" },
253 { "Hebrew (ISO-Visual)",
254 28598, MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
255 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
256 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
257 "iso-8859-8", "iso-8859-8", "iso-8859-8" }
259 static const MIME_CP_INFO japanese_cp[] =
261 { "Japanese (Shift-JIS)",
262 932, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
263 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
264 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
265 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
266 "shift_jis", "iso-2022-jp", "iso-2022-jp" },
267 { "Japanese (JIS 0208-1990 and 0212-1990)",
268 20932, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
269 MIMECONTF_MIME_LATEST,
270 "euc-jp", "euc-jp", "euc-jp" }
272 static const MIME_CP_INFO korean_cp[] =
275 949, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
276 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
277 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
278 MIMECONTF_MIME_LATEST,
279 "ks_c_5601-1987", "ks_c_5601-1987", "ks_c_5601-1987" }
281 static const MIME_CP_INFO thai_cp[] =
284 874, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_MIME_LATEST,
285 "ibm-thai", "ibm-thai", "ibm-thai" }
287 static const MIME_CP_INFO turkish_cp[] =
290 857, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
291 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
292 "ibm857", "ibm857", "ibm857" },
293 { "IBM EBCDIC (Turkish Latin-5)",
294 1026, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
295 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
296 "ibm1026", "ibm1026", "ibm1026" },
297 { "Turkish (Windows)",
298 1254, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
299 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
300 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
301 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
302 "windows-1254", "windows-1254", "windows-1254" },
304 10081, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
305 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
306 "x-mac-turkish", "x-mac-turkish", "x-mac-turkish" },
308 28593, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
309 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_EXPORT | MIMECONTF_VALID |
310 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
311 "iso-8859-3", "iso-8859-3", "iso-8859-3" },
313 28599, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
314 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
315 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
316 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
317 "iso-8859-9", "iso-8859-9", "iso-8859-9" }
319 static const MIME_CP_INFO vietnamese_cp[] =
321 { "Vietnamese (Windows)",
322 1258, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
323 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
324 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
325 MIMECONTF_MIME_LATEST,
326 "windows-1258", "windows-1258", "windows-1258" }
328 static const MIME_CP_INFO western_cp[] =
330 { "IBM EBCDIC (US-Canada)",
331 37, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
332 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
333 "ibm037", "ibm037", "ibm037" },
334 { "OEM United States",
335 437, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
336 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
337 "ibm437", "ibm437", "ibm437" },
338 { "IBM EBCDIC (International)",
339 500, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
340 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
341 "ibm500", "ibm500", "ibm500" },
342 { "Western European (DOS)",
343 850, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
344 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
345 "ibm850", "ibm850", "ibm850" },
346 { "Portuguese (DOS)",
347 860, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
348 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
349 "ibm860", "ibm860", "ibm860" },
351 861, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
352 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
353 "ibm861", "ibm861", "ibm861" },
354 { "French Canadian (DOS)",
355 863, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
356 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
357 "ibm863", "ibm863", "ibm863" },
359 865, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
360 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
361 "ibm865", "ibm865", "ibm865" },
362 { "Western European (Windows)",
363 1252, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
364 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
365 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
366 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
367 "windows-1252", "windows-1252", "iso-8859-1" },
368 { "Western European (Mac)",
369 10000, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
370 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
371 "macintosh", "macintosh", "macintosh" },
373 10079, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
374 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
375 "x-mac-icelandic", "x-mac-icelandic", "x-mac-icelandic" },
376 { "Western European (ISO)",
377 28591, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
378 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
379 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
380 MIMECONTF_MIME_LATEST,
381 "iso-8859-1", "iso-8859-1", "iso-8859-1" },
383 28605, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
384 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
385 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
386 MIMECONTF_MIME_LATEST,
387 "iso-8859-15", "iso-8859-15", "iso-8859-15" }
389 static const MIME_CP_INFO unicode_cp[] =
392 CP_UNICODE, MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
393 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
394 MIMECONTF_VALID | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
395 MIMECONTF_MIME_LATEST,
396 "unicode", "unicode", "unicode" },
398 CP_UTF7, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
399 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_EXPORT | MIMECONTF_VALID |
400 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
401 "utf-7", "utf-7", "utf-7" },
403 CP_UTF8, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
404 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
405 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
406 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
407 "utf-8", "utf-8", "utf-8" }
410 static const struct mlang_data
412 const char *description;
413 UINT family_codepage;
415 const MIME_CP_INFO *mime_cp_info;
416 const char *fixed_font;
417 const char *proportional_font;
420 { "Arabic",1256,sizeof(arabic_cp)/sizeof(arabic_cp[0]),arabic_cp,
421 "Courier","Arial" }, /* FIXME */
422 { "Baltic",1257,sizeof(baltic_cp)/sizeof(baltic_cp[0]),baltic_cp,
423 "Courier","Arial" }, /* FIXME */
424 { "Chinese Simplified",936,sizeof(chinese_simplified_cp)/sizeof(chinese_simplified_cp[0]),chinese_simplified_cp,
425 "Courier","Arial" }, /* FIXME */
426 { "Chinese Traditional",950,sizeof(chinese_traditional_cp)/sizeof(chinese_traditional_cp[0]),chinese_traditional_cp,
427 "Courier","Arial" }, /* FIXME */
428 { "Central European",1250,sizeof(central_european_cp)/sizeof(central_european_cp[0]),central_european_cp,
429 "Courier","Arial" }, /* FIXME */
430 { "Cyrillic",1251,sizeof(cyrillic_cp)/sizeof(cyrillic_cp[0]),cyrillic_cp,
431 "Courier","Arial" }, /* FIXME */
432 { "Greek",1253,sizeof(greek_cp)/sizeof(greek_cp[0]),greek_cp,
433 "Courier","Arial" }, /* FIXME */
434 { "Hebrew",1255,sizeof(hebrew_cp)/sizeof(hebrew_cp[0]),hebrew_cp,
435 "Courier","Arial" }, /* FIXME */
436 { "Japanese",932,sizeof(japanese_cp)/sizeof(japanese_cp[0]),japanese_cp,
437 "Courier","Arial" }, /* FIXME */
438 { "Korean",949,sizeof(korean_cp)/sizeof(korean_cp[0]),korean_cp,
439 "Courier","Arial" }, /* FIXME */
440 { "Thai",874,sizeof(thai_cp)/sizeof(thai_cp[0]),thai_cp,
441 "Courier","Arial" }, /* FIXME */
442 { "Turkish",1254,sizeof(turkish_cp)/sizeof(turkish_cp[0]),turkish_cp,
443 "Courier","Arial" }, /* FIXME */
444 { "Vietnamese",1258,sizeof(vietnamese_cp)/sizeof(vietnamese_cp[0]),vietnamese_cp,
445 "Courier","Arial" }, /* FIXME */
446 { "Western European",1252,sizeof(western_cp)/sizeof(western_cp[0]),western_cp,
447 "Courier","Arial" }, /* FIXME */
448 { "Unicode",CP_UNICODE,sizeof(unicode_cp)/sizeof(unicode_cp[0]),unicode_cp,
449 "Courier","Arial" } /* FIXME */
452 static void fill_cp_info(const struct mlang_data *ml_data, UINT index, MIMECPINFO *mime_cp_info);
454 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
457 case DLL_PROCESS_ATTACH:
458 DisableThreadLibraryCalls(hInstDLL);
460 case DLL_PROCESS_DETACH:
466 HRESULT WINAPI ConvertINetMultiByteToUnicode(
476 TRACE("%p %ld %s %p %p %p\n", pdwMode, dwEncoding,
477 debugstr_a(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
483 pcSrcSize = &src_len;
494 if (*pcSrcSize == -1)
495 *pcSrcSize = lstrlenW((LPCWSTR)pSrcStr);
496 *pcDstSize = min(*pcSrcSize, *pcDstSize);
497 *pcSrcSize *= sizeof(WCHAR);
499 memmove(pDstStr, pSrcStr, *pcDstSize * sizeof(WCHAR));
503 if (*pcSrcSize == -1)
504 *pcSrcSize = lstrlenA(pSrcStr);
507 *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, pDstStr, *pcDstSize);
509 *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, NULL, 0);
519 HRESULT WINAPI ConvertINetUnicodeToMultiByte(
530 TRACE("%p %ld %s %p %p %p\n", pdwMode, dwEncoding,
531 debugstr_w(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
537 pcSrcSize = &src_len;
548 if (*pcSrcSize == -1)
549 *pcSrcSize = lstrlenW(pSrcStr);
550 *pcDstSize = min(*pcSrcSize * sizeof(WCHAR), *pcDstSize);
552 memmove(pDstStr, pSrcStr, *pcDstSize);
556 if (*pcSrcSize == -1)
557 *pcSrcSize = lstrlenW(pSrcStr);
560 *pcDstSize = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize, pDstStr, *pcDstSize, NULL, NULL);
562 *pcDstSize = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize, NULL, 0, NULL, NULL);
573 HRESULT WINAPI ConvertINetString(
583 FIXME("%p %ld %ld %s %p %p %p: stub!\n", pdwMode, dwSrcEncoding, dwDstEncoding,
584 debugstr_a(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
588 static HRESULT GetFamilyCodePage(
590 UINT* puiFamilyCodePage)
594 TRACE("%u %p\n", uiCodePage, puiFamilyCodePage);
596 if (!puiFamilyCodePage) return S_FALSE;
598 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
600 for (n = 0; n < mlang_data[i].number_of_cp; n++)
602 if (mlang_data[i].mime_cp_info[n].cp == uiCodePage)
604 *puiFamilyCodePage = mlang_data[i].family_codepage;
613 HRESULT WINAPI IsConvertINetStringAvailable(
617 UINT src_family, dst_family;
619 TRACE("%ld %ld\n", dwSrcEncoding, dwDstEncoding);
621 if (GetFamilyCodePage(dwSrcEncoding, &src_family) != S_OK ||
622 GetFamilyCodePage(dwDstEncoding, &dst_family) != S_OK)
625 if (src_family == dst_family) return S_OK;
627 /* we can convert any codepage to/from unicode */
628 if (src_family == CP_UNICODE || dst_family == CP_UNICODE) return S_OK;
633 HRESULT WINAPI LcidToRfc1766A(
638 FIXME("%ld %s %u\n", Locale, pszRfc1766, nChar);
642 HRESULT WINAPI LcidToRfc1766W(
647 FIXME("%ld %p %u\n", Locale, pszRfc1766, nChar);
651 /******************************************************************************
655 IClassFactory ITF_IClassFactory;
658 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
661 struct object_creation_info
665 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
668 static const struct object_creation_info object_creation[] =
670 { &CLSID_CMultiLanguage, "CLSID_CMultiLanguage", MultiLanguage_create },
673 static HRESULT WINAPI
674 MLANGCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
676 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
678 TRACE("%s\n", debugstr_guid(riid) );
680 if (IsEqualGUID(riid, &IID_IUnknown)
681 || IsEqualGUID(riid, &IID_IClassFactory))
683 IClassFactory_AddRef(iface);
688 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
689 return E_NOINTERFACE;
692 static ULONG WINAPI MLANGCF_AddRef(LPCLASSFACTORY iface)
694 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
695 return InterlockedIncrement(&This->ref);
698 static ULONG WINAPI MLANGCF_Release(LPCLASSFACTORY iface)
700 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
702 ULONG ref = InterlockedDecrement(&This->ref);
706 TRACE("Destroying %p\n", This);
707 HeapFree(GetProcessHeap(), 0, This);
713 static HRESULT WINAPI MLANGCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
714 REFIID riid, LPVOID *ppobj)
716 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
720 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
723 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
724 if (SUCCEEDED(hres)) {
725 hres = IUnknown_QueryInterface(punk, riid, ppobj);
726 IUnknown_Release(punk);
728 TRACE("returning (%p) -> %lx\n", *ppobj, hres);
732 static HRESULT WINAPI MLANGCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
734 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
735 FIXME("(%p)->(%d),stub!\n",This,dolock);
739 static const IClassFactoryVtbl MLANGCF_Vtbl =
741 MLANGCF_QueryInterface,
744 MLANGCF_CreateInstance,
748 /******************************************************************
749 * DllGetClassObject (MLANG.@)
751 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
754 IClassFactoryImpl *factory;
756 TRACE("%s %s %p\n",debugstr_guid(rclsid), debugstr_guid(iid), ppv);
758 if ( !IsEqualGUID( &IID_IClassFactory, iid )
759 && ! IsEqualGUID( &IID_IUnknown, iid) )
760 return E_NOINTERFACE;
762 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
764 if (IsEqualGUID(object_creation[i].clsid, rclsid))
768 if (i == sizeof(object_creation)/sizeof(object_creation[0]))
770 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
771 return CLASS_E_CLASSNOTAVAILABLE;
774 TRACE("Creating a class factory for %s\n",object_creation[i].szClassName);
776 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
777 if (factory == NULL) return E_OUTOFMEMORY;
779 factory->ITF_IClassFactory.lpVtbl = &MLANGCF_Vtbl;
782 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
784 *ppv = &(factory->ITF_IClassFactory);
786 TRACE("(%p) <- %p\n", ppv, &(factory->ITF_IClassFactory) );
792 /******************************************************************************/
794 typedef struct tagMLang_impl
796 const IMLangFontLinkVtbl *vtbl_IMLangFontLink;
797 const IMultiLanguageVtbl *vtbl_IMultiLanguage;
798 const IMultiLanguage2Vtbl *vtbl_IMultiLanguage2;
800 DWORD total_cp, total_scripts;
803 static ULONG WINAPI MLang_AddRef( MLang_impl* This)
805 return InterlockedIncrement(&This->ref);
808 static ULONG WINAPI MLang_Release( MLang_impl* This )
810 ULONG ref = InterlockedDecrement(&This->ref);
812 TRACE("%p ref = %ld\n", This, ref);
815 TRACE("Destroying %p\n", This);
816 HeapFree(GetProcessHeap(), 0, This);
822 static HRESULT WINAPI MLang_QueryInterface(
827 TRACE("%p -> %s\n", This, debugstr_guid(riid) );
829 if (IsEqualGUID(riid, &IID_IUnknown)
830 || IsEqualGUID(riid, &IID_IMLangCodePages)
831 || IsEqualGUID(riid, &IID_IMLangFontLink))
834 TRACE("Returning IID_IMLangFontLink %p ref = %ld\n", This, This->ref);
835 *ppvObject = &(This->vtbl_IMLangFontLink);
839 if (IsEqualGUID(riid, &IID_IMultiLanguage) )
842 TRACE("Returning IID_IMultiLanguage %p ref = %ld\n", This, This->ref);
843 *ppvObject = &(This->vtbl_IMultiLanguage);
847 if (IsEqualGUID(riid, &IID_IMultiLanguage2) )
850 *ppvObject = &(This->vtbl_IMultiLanguage2);
851 TRACE("Returning IID_IMultiLanguage2 %p ref = %ld\n", This, This->ref);
855 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
856 return E_NOINTERFACE;
859 /******************************************************************************/
861 typedef struct tagEnumCodePage_impl
863 const IEnumCodePageVtbl *vtbl_IEnumCodePage;
869 static HRESULT WINAPI fnIEnumCodePage_QueryInterface(
870 IEnumCodePage* iface,
874 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
876 TRACE("%p -> %s\n", This, debugstr_guid(riid) );
878 if (IsEqualGUID(riid, &IID_IUnknown)
879 || IsEqualGUID(riid, &IID_IEnumCodePage))
881 IEnumCodePage_AddRef(iface);
882 TRACE("Returning IID_IEnumCodePage %p ref = %ld\n", This, This->ref);
883 *ppvObject = &(This->vtbl_IEnumCodePage);
887 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
888 return E_NOINTERFACE;
891 static ULONG WINAPI fnIEnumCodePage_AddRef(
892 IEnumCodePage* iface)
894 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
895 return InterlockedIncrement(&This->ref);
898 static ULONG WINAPI fnIEnumCodePage_Release(
899 IEnumCodePage* iface)
901 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
902 ULONG ref = InterlockedDecrement(&This->ref);
904 TRACE("%p ref = %ld\n", This, ref);
907 TRACE("Destroying %p\n", This);
908 HeapFree(GetProcessHeap(), 0, This->cpinfo);
909 HeapFree(GetProcessHeap(), 0, This);
915 static HRESULT WINAPI fnIEnumCodePage_Clone(
916 IEnumCodePage* iface,
917 IEnumCodePage** ppEnum)
919 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
920 FIXME("%p %p\n", This, ppEnum);
924 static HRESULT WINAPI fnIEnumCodePage_Next(
925 IEnumCodePage* iface,
932 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
933 TRACE("%p %lu %p %p\n", This, celt, rgelt, pceltFetched);
935 if (!pceltFetched) return S_FALSE;
938 if (!rgelt) return S_FALSE;
940 if (This->pos + celt > This->total)
941 celt = This->total - This->pos;
943 if (!celt) return S_FALSE;
945 memcpy(rgelt, This->cpinfo + This->pos, celt * sizeof(MIMECPINFO));
946 *pceltFetched = celt;
949 for (i = 0; i < celt; i++)
951 TRACE("#%lu: %08lx %u %u %s %s %s %s %s %s %d\n",
952 i, rgelt[i].dwFlags, rgelt[i].uiCodePage,
953 rgelt[i].uiFamilyCodePage,
954 wine_dbgstr_w(rgelt[i].wszDescription),
955 wine_dbgstr_w(rgelt[i].wszWebCharset),
956 wine_dbgstr_w(rgelt[i].wszHeaderCharset),
957 wine_dbgstr_w(rgelt[i].wszBodyCharset),
958 wine_dbgstr_w(rgelt[i].wszFixedWidthFont),
959 wine_dbgstr_w(rgelt[i].wszProportionalFont),
960 rgelt[i].bGDICharset);
965 static HRESULT WINAPI fnIEnumCodePage_Reset(
966 IEnumCodePage* iface)
968 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
975 static HRESULT WINAPI fnIEnumCodePage_Skip(
976 IEnumCodePage* iface,
979 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
980 TRACE("%p %lu\n", This, celt);
982 if (celt >= This->total) return S_FALSE;
984 This->pos = celt; /* FIXME: should be += ?? */
988 static const IEnumCodePageVtbl IEnumCodePage_vtbl =
990 fnIEnumCodePage_QueryInterface,
991 fnIEnumCodePage_AddRef,
992 fnIEnumCodePage_Release,
993 fnIEnumCodePage_Clone,
994 fnIEnumCodePage_Next,
995 fnIEnumCodePage_Reset,
999 static HRESULT EnumCodePage_create( MLang_impl* mlang, DWORD grfFlags,
1000 LANGID LangId, IEnumCodePage** ppEnumCodePage )
1002 EnumCodePage_impl *ecp;
1006 TRACE("%p, %08lx, %04x, %p\n", mlang, grfFlags, LangId, ppEnumCodePage);
1008 if (!grfFlags) /* enumerate internal data base of encodings */
1009 grfFlags = MIMECONTF_MIME_LATEST;
1011 ecp = HeapAlloc( GetProcessHeap(), 0, sizeof (EnumCodePage_impl) );
1012 ecp->vtbl_IEnumCodePage = &IEnumCodePage_vtbl;
1016 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1018 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1020 if (mlang_data[i].mime_cp_info[n].flags & grfFlags)
1025 ecp->cpinfo = HeapAlloc(GetProcessHeap(), 0,
1026 sizeof(MIMECPINFO) * ecp->total);
1027 cpinfo = ecp->cpinfo;
1029 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1031 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1033 if (mlang_data[i].mime_cp_info[n].flags & grfFlags)
1034 fill_cp_info(&mlang_data[i], n, cpinfo++);
1038 TRACE("enumerated %ld codepages with flags %08lx\n", ecp->total, grfFlags);
1040 *ppEnumCodePage = (IEnumCodePage*) ecp;
1045 /******************************************************************************/
1047 typedef struct tagEnumScript_impl
1049 const IEnumScriptVtbl *vtbl_IEnumScript;
1051 SCRIPTINFO *script_info;
1055 static HRESULT WINAPI fnIEnumScript_QueryInterface(
1060 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1062 TRACE("%p -> %s\n", This, debugstr_guid(riid) );
1064 if (IsEqualGUID(riid, &IID_IUnknown)
1065 || IsEqualGUID(riid, &IID_IEnumScript))
1067 IEnumScript_AddRef(iface);
1068 TRACE("Returning IID_IEnumScript %p ref = %ld\n", This, This->ref);
1069 *ppvObject = &(This->vtbl_IEnumScript);
1073 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
1074 return E_NOINTERFACE;
1077 static ULONG WINAPI fnIEnumScript_AddRef(
1080 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1081 return InterlockedIncrement(&This->ref);
1084 static ULONG WINAPI fnIEnumScript_Release(
1087 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1088 ULONG ref = InterlockedDecrement(&This->ref);
1090 TRACE("%p ref = %ld\n", This, ref);
1093 TRACE("Destroying %p\n", This);
1094 HeapFree(GetProcessHeap(), 0, This);
1100 static HRESULT WINAPI fnIEnumScript_Clone(
1102 IEnumScript** ppEnum)
1104 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1105 FIXME("%p %p: stub!\n", This, ppEnum);
1109 static HRESULT WINAPI fnIEnumScript_Next(
1113 ULONG* pceltFetched)
1115 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1116 TRACE("%p %lu %p %p\n", This, celt, rgelt, pceltFetched);
1118 if (!pceltFetched || !rgelt) return E_FAIL;
1122 if (This->pos + celt > This->total)
1123 celt = This->total - This->pos;
1125 if (!celt) return S_FALSE;
1127 memcpy(rgelt, This->script_info + This->pos, celt * sizeof(SCRIPTINFO));
1128 *pceltFetched = celt;
1134 static HRESULT WINAPI fnIEnumScript_Reset(
1137 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1138 TRACE("%p\n", This);
1144 static HRESULT WINAPI fnIEnumScript_Skip(
1148 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1149 TRACE("%p %lu\n", This, celt);
1151 if (celt >= This->total) return S_FALSE;
1153 This->pos = celt; /* FIXME: should be += ?? */
1157 static const IEnumScriptVtbl IEnumScript_vtbl =
1159 fnIEnumScript_QueryInterface,
1160 fnIEnumScript_AddRef,
1161 fnIEnumScript_Release,
1162 fnIEnumScript_Clone,
1164 fnIEnumScript_Reset,
1168 static HRESULT EnumScript_create( MLang_impl* mlang, DWORD dwFlags,
1169 LANGID LangId, IEnumScript** ppEnumScript )
1171 EnumScript_impl *es;
1174 TRACE("%p, %08lx, %04x, %p: stub!\n", mlang, dwFlags, LangId, ppEnumScript);
1176 if (!dwFlags) /* enumerate all available scripts */
1177 dwFlags = SCRIPTCONTF_SCRIPT_USER | SCRIPTCONTF_SCRIPT_HIDE | SCRIPTCONTF_SCRIPT_SYSTEM;
1179 es = HeapAlloc( GetProcessHeap(), 0, sizeof (EnumScript_impl) );
1180 es->vtbl_IEnumScript = &IEnumScript_vtbl;
1183 /* do not enumerate unicode flavours */
1184 es->total = sizeof(mlang_data)/sizeof(mlang_data[0]) - 1;
1185 es->script_info = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPTINFO) * es->total);
1187 for (i = 0; i < es->total; i++)
1189 es->script_info[i].ScriptId = i;
1190 es->script_info[i].uiCodePage = mlang_data[i].family_codepage;
1191 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].description, -1,
1192 es->script_info[i].wszDescription, MAX_SCRIPT_NAME);
1193 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].fixed_font, -1,
1194 es->script_info[i].wszFixedWidthFont, MAX_MIMEFACE_NAME);
1195 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].proportional_font, -1,
1196 es->script_info[i].wszProportionalFont, MAX_MIMEFACE_NAME);
1199 TRACE("enumerated %ld scripts with flags %08lx\n", es->total, dwFlags);
1201 *ppEnumScript = (IEnumScript *)es;
1206 /******************************************************************************/
1208 static HRESULT WINAPI fnIMLangFontLink_QueryInterface(
1209 IMLangFontLink* iface,
1213 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
1214 return MLang_QueryInterface( This, riid, ppvObject );
1217 static ULONG WINAPI fnIMLangFontLink_AddRef(
1218 IMLangFontLink* iface)
1220 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
1221 return MLang_AddRef( This );
1224 static ULONG WINAPI fnIMLangFontLink_Release(
1225 IMLangFontLink* iface)
1227 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
1228 return MLang_Release( This );
1231 static HRESULT WINAPI fnIMLangFontLink_GetCharCodePages(
1232 IMLangFontLink* iface,
1234 DWORD* pdwCodePages)
1240 static HRESULT WINAPI fnIMLangFontLink_GetStrCodePages(
1241 IMLangFontLink* iface,
1242 const WCHAR* pszSrc,
1244 DWORD dwPriorityCodePages,
1245 DWORD* pdwCodePages,
1246 long* pcchCodePages)
1252 static HRESULT WINAPI fnIMLangFontLink_CodePageToCodePages(
1253 IMLangFontLink* iface,
1255 DWORD* pdwCodePages)
1261 static HRESULT WINAPI fnIMLangFontLink_CodePagesToCodePage(
1262 IMLangFontLink* iface,
1264 UINT uDefaultCodePage,
1271 static HRESULT WINAPI fnIMLangFontLink_GetFontCodePages(
1272 IMLangFontLink* iface,
1275 DWORD* pdwCodePages)
1281 static HRESULT WINAPI fnIMLangFontLink_MapFont(
1282 IMLangFontLink* iface,
1292 static HRESULT WINAPI fnIMLangFontLink_ReleaseFont(
1293 IMLangFontLink* iface,
1300 static HRESULT WINAPI fnIMLangFontLink_ResetFontMapping(
1301 IMLangFontLink* iface)
1308 static const IMLangFontLinkVtbl IMLangFontLink_vtbl =
1310 fnIMLangFontLink_QueryInterface,
1311 fnIMLangFontLink_AddRef,
1312 fnIMLangFontLink_Release,
1313 fnIMLangFontLink_GetCharCodePages,
1314 fnIMLangFontLink_GetStrCodePages,
1315 fnIMLangFontLink_CodePageToCodePages,
1316 fnIMLangFontLink_CodePagesToCodePage,
1317 fnIMLangFontLink_GetFontCodePages,
1318 fnIMLangFontLink_MapFont,
1319 fnIMLangFontLink_ReleaseFont,
1320 fnIMLangFontLink_ResetFontMapping,
1323 /******************************************************************************/
1325 static HRESULT WINAPI fnIMultiLanguage_QueryInterface(
1326 IMultiLanguage* iface,
1330 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1331 return MLang_QueryInterface( This, riid, ppvObject );
1334 static ULONG WINAPI fnIMultiLanguage_AddRef( IMultiLanguage* iface )
1336 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1337 return IMLangFontLink_AddRef( ((IMLangFontLink*)This) );
1340 static ULONG WINAPI fnIMultiLanguage_Release( IMultiLanguage* iface )
1342 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1343 return IMLangFontLink_Release( ((IMLangFontLink*)This) );
1346 static HRESULT WINAPI fnIMultiLanguage_GetNumberOfCodePageInfo(
1347 IMultiLanguage* iface,
1354 static HRESULT WINAPI fnIMultiLanguage_GetCodePageInfo(
1355 IMultiLanguage* iface,
1357 PMIMECPINFO pCodePageInfo)
1363 static HRESULT WINAPI fnIMultiLanguage_GetFamilyCodePage(
1364 IMultiLanguage* iface,
1366 UINT* puiFamilyCodePage)
1368 return GetFamilyCodePage(uiCodePage, puiFamilyCodePage);
1371 static HRESULT WINAPI fnIMultiLanguage_EnumCodePages(
1372 IMultiLanguage* iface,
1374 IEnumCodePage** ppEnumCodePage)
1376 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1377 TRACE("%p %08lx %p\n", This, grfFlags, ppEnumCodePage);
1379 return EnumCodePage_create( This, grfFlags, 0, ppEnumCodePage );
1382 static HRESULT WINAPI fnIMultiLanguage_GetCharsetInfo(
1383 IMultiLanguage* iface,
1385 PMIMECSETINFO pCharsetInfo)
1391 static HRESULT WINAPI fnIMultiLanguage_IsConvertible(
1392 IMultiLanguage* iface,
1393 DWORD dwSrcEncoding,
1394 DWORD dwDstEncoding)
1396 return IsConvertINetStringAvailable(dwSrcEncoding, dwDstEncoding);
1399 static HRESULT WINAPI fnIMultiLanguage_ConvertString(
1400 IMultiLanguage* iface,
1402 DWORD dwSrcEncoding,
1403 DWORD dwDstEncoding,
1409 return ConvertINetString(pdwMode, dwSrcEncoding, dwDstEncoding,
1410 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1413 static HRESULT WINAPI fnIMultiLanguage_ConvertStringToUnicode(
1414 IMultiLanguage* iface,
1422 return ConvertINetMultiByteToUnicode(pdwMode, dwEncoding,
1423 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1426 static HRESULT WINAPI fnIMultiLanguage_ConvertStringFromUnicode(
1427 IMultiLanguage* iface,
1435 return ConvertINetUnicodeToMultiByte(pdwMode, dwEncoding,
1436 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1439 static HRESULT WINAPI fnIMultiLanguage_ConvertStringReset(
1440 IMultiLanguage* iface)
1446 static HRESULT WINAPI fnIMultiLanguage_GetRfc1766FromLcid(
1447 IMultiLanguage* iface,
1455 static HRESULT WINAPI fnIMultiLanguage_GetLcidFromRfc1766(
1456 IMultiLanguage* iface,
1464 static HRESULT WINAPI fnIMultiLanguage_EnumRfc1766(
1465 IMultiLanguage* iface,
1466 IEnumRfc1766** ppEnumRfc1766)
1472 static HRESULT WINAPI fnIMultiLanguage_GetRfc1766Info(
1473 IMultiLanguage* iface,
1475 PRFC1766INFO pRfc1766Info)
1481 static HRESULT WINAPI fnIMultiLanguage_CreateConvertCharset(
1482 IMultiLanguage* iface,
1486 IMLangConvertCharset** ppMLangConvertCharset)
1492 static const IMultiLanguageVtbl IMultiLanguage_vtbl =
1494 fnIMultiLanguage_QueryInterface,
1495 fnIMultiLanguage_AddRef,
1496 fnIMultiLanguage_Release,
1497 fnIMultiLanguage_GetNumberOfCodePageInfo,
1498 fnIMultiLanguage_GetCodePageInfo,
1499 fnIMultiLanguage_GetFamilyCodePage,
1500 fnIMultiLanguage_EnumCodePages,
1501 fnIMultiLanguage_GetCharsetInfo,
1502 fnIMultiLanguage_IsConvertible,
1503 fnIMultiLanguage_ConvertString,
1504 fnIMultiLanguage_ConvertStringToUnicode,
1505 fnIMultiLanguage_ConvertStringFromUnicode,
1506 fnIMultiLanguage_ConvertStringReset,
1507 fnIMultiLanguage_GetRfc1766FromLcid,
1508 fnIMultiLanguage_GetLcidFromRfc1766,
1509 fnIMultiLanguage_EnumRfc1766,
1510 fnIMultiLanguage_GetRfc1766Info,
1511 fnIMultiLanguage_CreateConvertCharset,
1515 /******************************************************************************/
1517 static HRESULT WINAPI fnIMultiLanguage2_QueryInterface(
1518 IMultiLanguage2* iface,
1522 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1523 return MLang_QueryInterface( This, riid, ppvObject );
1526 static ULONG WINAPI fnIMultiLanguage2_AddRef( IMultiLanguage2* iface )
1528 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1529 return MLang_AddRef( This );
1532 static ULONG WINAPI fnIMultiLanguage2_Release( IMultiLanguage2* iface )
1534 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1535 return MLang_Release( This );
1538 static HRESULT WINAPI fnIMultiLanguage2_GetNumberOfCodePageInfo(
1539 IMultiLanguage2* iface,
1542 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1543 TRACE("%p, %p\n", This, pcCodePage);
1545 if (!pcCodePage) return S_FALSE;
1547 *pcCodePage = This->total_cp;
1551 static void fill_cp_info(const struct mlang_data *ml_data, UINT index, MIMECPINFO *mime_cp_info)
1555 if (TranslateCharsetInfo((DWORD *)ml_data->family_codepage, &csi, TCI_SRCCODEPAGE))
1556 mime_cp_info->bGDICharset = csi.ciCharset;
1558 mime_cp_info->bGDICharset = DEFAULT_CHARSET;
1560 mime_cp_info->dwFlags = ml_data->mime_cp_info[index].flags;
1561 mime_cp_info->uiCodePage = ml_data->mime_cp_info[index].cp;
1562 mime_cp_info->uiFamilyCodePage = ml_data->family_codepage;
1563 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].description, -1,
1564 mime_cp_info->wszDescription, sizeof(mime_cp_info->wszDescription)/sizeof(WCHAR));
1565 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].web_charset, -1,
1566 mime_cp_info->wszWebCharset, sizeof(mime_cp_info->wszWebCharset)/sizeof(WCHAR));
1567 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].header_charset, -1,
1568 mime_cp_info->wszHeaderCharset, sizeof(mime_cp_info->wszHeaderCharset)/sizeof(WCHAR));
1569 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].body_charset, -1,
1570 mime_cp_info->wszBodyCharset, sizeof(mime_cp_info->wszBodyCharset)/sizeof(WCHAR));
1572 MultiByteToWideChar(CP_ACP, 0, ml_data->fixed_font, -1,
1573 mime_cp_info->wszFixedWidthFont, sizeof(mime_cp_info->wszFixedWidthFont)/sizeof(WCHAR));
1574 MultiByteToWideChar(CP_ACP, 0, ml_data->proportional_font, -1,
1575 mime_cp_info->wszProportionalFont, sizeof(mime_cp_info->wszProportionalFont)/sizeof(WCHAR));
1577 TRACE("%08lx %u %u %s %s %s %s %s %s %d\n",
1578 mime_cp_info->dwFlags, mime_cp_info->uiCodePage,
1579 mime_cp_info->uiFamilyCodePage,
1580 wine_dbgstr_w(mime_cp_info->wszDescription),
1581 wine_dbgstr_w(mime_cp_info->wszWebCharset),
1582 wine_dbgstr_w(mime_cp_info->wszHeaderCharset),
1583 wine_dbgstr_w(mime_cp_info->wszBodyCharset),
1584 wine_dbgstr_w(mime_cp_info->wszFixedWidthFont),
1585 wine_dbgstr_w(mime_cp_info->wszProportionalFont),
1586 mime_cp_info->bGDICharset);
1589 static HRESULT WINAPI fnIMultiLanguage2_GetCodePageInfo(
1590 IMultiLanguage2* iface,
1593 PMIMECPINFO pCodePageInfo)
1597 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1598 TRACE("%p, %u, %04x, %p\n", This, uiCodePage, LangId, pCodePageInfo);
1600 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1602 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1604 if (mlang_data[i].mime_cp_info[n].cp == uiCodePage)
1606 fill_cp_info(&mlang_data[i], n, pCodePageInfo);
1615 static HRESULT WINAPI fnIMultiLanguage2_GetFamilyCodePage(
1616 IMultiLanguage2* iface,
1618 UINT* puiFamilyCodePage)
1620 return GetFamilyCodePage(uiCodePage, puiFamilyCodePage);
1623 static HRESULT WINAPI fnIMultiLanguage2_EnumCodePages(
1624 IMultiLanguage2* iface,
1627 IEnumCodePage** ppEnumCodePage)
1629 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1630 TRACE("%p %08lx %04x %p\n", This, grfFlags, LangId, ppEnumCodePage);
1632 return EnumCodePage_create( This, grfFlags, LangId, ppEnumCodePage );
1635 static HRESULT WINAPI fnIMultiLanguage2_GetCharsetInfo(
1636 IMultiLanguage2* iface,
1638 PMIMECSETINFO pCharsetInfo)
1642 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1643 TRACE("%p %s %p\n", This, debugstr_w(Charset), pCharsetInfo);
1645 if (!pCharsetInfo) return E_FAIL;
1647 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1649 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1651 WCHAR csetW[MAX_MIMECSET_NAME];
1653 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].mime_cp_info[n].web_charset, -1, csetW, MAX_MIMECSET_NAME);
1654 if (!lstrcmpiW(Charset, csetW))
1656 pCharsetInfo->uiCodePage = mlang_data[i].family_codepage;
1657 pCharsetInfo->uiInternetEncoding = mlang_data[i].mime_cp_info[n].cp;
1658 strcpyW(pCharsetInfo->wszCharset, csetW);
1665 * Since we do not support charsets like iso-2022-jp and do not have
1666 * them in our database as a primary (web_charset) encoding this loop
1667 * does an attempt to 'approximate' charset name by header_charset.
1669 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1671 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1673 WCHAR csetW[MAX_MIMECSET_NAME];
1675 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].mime_cp_info[n].header_charset, -1, csetW, MAX_MIMECSET_NAME);
1676 if (!lstrcmpiW(Charset, csetW))
1678 pCharsetInfo->uiCodePage = mlang_data[i].family_codepage;
1679 pCharsetInfo->uiInternetEncoding = mlang_data[i].mime_cp_info[n].cp;
1680 strcpyW(pCharsetInfo->wszCharset, csetW);
1689 static HRESULT WINAPI fnIMultiLanguage2_IsConvertible(
1690 IMultiLanguage2* iface,
1691 DWORD dwSrcEncoding,
1692 DWORD dwDstEncoding)
1694 return IsConvertINetStringAvailable(dwSrcEncoding, dwDstEncoding);
1697 static HRESULT WINAPI fnIMultiLanguage2_ConvertString(
1698 IMultiLanguage2* iface,
1700 DWORD dwSrcEncoding,
1701 DWORD dwDstEncoding,
1707 return ConvertINetString(pdwMode, dwSrcEncoding, dwDstEncoding,
1708 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1711 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringToUnicode(
1712 IMultiLanguage2* iface,
1720 return ConvertINetMultiByteToUnicode(pdwMode, dwEncoding,
1721 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1724 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringFromUnicode(
1725 IMultiLanguage2* iface,
1733 return ConvertINetUnicodeToMultiByte(pdwMode, dwEncoding,
1734 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1737 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringReset(
1738 IMultiLanguage2* iface)
1744 static HRESULT WINAPI fnIMultiLanguage2_GetRfc1766FromLcid(
1745 IMultiLanguage2* iface,
1753 static HRESULT WINAPI fnIMultiLanguage2_GetLcidFromRfc1766(
1754 IMultiLanguage2* iface,
1762 static HRESULT WINAPI fnIMultiLanguage2_EnumRfc1766(
1763 IMultiLanguage2* iface,
1765 IEnumRfc1766** ppEnumRfc1766)
1771 static HRESULT WINAPI fnIMultiLanguage2_GetRfc1766Info(
1772 IMultiLanguage2* iface,
1775 PRFC1766INFO pRfc1766Info)
1781 static HRESULT WINAPI fnIMultiLanguage2_CreateConvertCharset(
1782 IMultiLanguage2* iface,
1786 IMLangConvertCharset** ppMLangConvertCharset)
1792 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringInIStream(
1793 IMultiLanguage2* iface,
1797 DWORD dwSrcEncoding,
1798 DWORD dwDstEncoding,
1806 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringToUnicodeEx(
1807 IMultiLanguage2* iface,
1821 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringFromUnicodeEx(
1822 IMultiLanguage2* This,
1836 static HRESULT WINAPI fnIMultiLanguage2_DetectCodepageInIStream(
1837 IMultiLanguage2* iface,
1839 DWORD dwPrefWinCodePage,
1841 DetectEncodingInfo* lpEncoding,
1848 static HRESULT WINAPI fnIMultiLanguage2_DetectInputCodepage(
1849 IMultiLanguage2* iface,
1851 DWORD dwPrefWinCodePage,
1854 DetectEncodingInfo* lpEncoding,
1861 static HRESULT WINAPI fnIMultiLanguage2_ValidateCodePage(
1862 IMultiLanguage2* iface,
1870 static HRESULT WINAPI fnIMultiLanguage2_GetCodePageDescription(
1871 IMultiLanguage2* iface,
1874 LPWSTR lpWideCharStr,
1881 static HRESULT WINAPI fnIMultiLanguage2_IsCodePageInstallable(
1882 IMultiLanguage2* iface,
1889 static HRESULT WINAPI fnIMultiLanguage2_SetMimeDBSource(
1890 IMultiLanguage2* iface,
1897 static HRESULT WINAPI fnIMultiLanguage2_GetNumberOfScripts(
1898 IMultiLanguage2* iface,
1901 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1902 TRACE("%p %p\n", This, pnScripts);
1904 if (!pnScripts) return S_FALSE;
1906 *pnScripts = This->total_scripts;
1910 static HRESULT WINAPI fnIMultiLanguage2_EnumScripts(
1911 IMultiLanguage2* iface,
1914 IEnumScript** ppEnumScript)
1916 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1917 TRACE("%p %08lx %04x %p\n", This, dwFlags, LangId, ppEnumScript);
1919 return EnumScript_create( This, dwFlags, LangId, ppEnumScript );
1922 static HRESULT WINAPI fnIMultiLanguage2_ValidateCodePageEx(
1923 IMultiLanguage2* iface,
1926 DWORD dwfIODControl)
1928 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1929 FIXME("%p %u %p %08lx: stub!\n", This, uiCodePage, hwnd, dwfIODControl);
1934 static const IMultiLanguage2Vtbl IMultiLanguage2_vtbl =
1936 fnIMultiLanguage2_QueryInterface,
1937 fnIMultiLanguage2_AddRef,
1938 fnIMultiLanguage2_Release,
1939 fnIMultiLanguage2_GetNumberOfCodePageInfo,
1940 fnIMultiLanguage2_GetCodePageInfo,
1941 fnIMultiLanguage2_GetFamilyCodePage,
1942 fnIMultiLanguage2_EnumCodePages,
1943 fnIMultiLanguage2_GetCharsetInfo,
1944 fnIMultiLanguage2_IsConvertible,
1945 fnIMultiLanguage2_ConvertString,
1946 fnIMultiLanguage2_ConvertStringToUnicode,
1947 fnIMultiLanguage2_ConvertStringFromUnicode,
1948 fnIMultiLanguage2_ConvertStringReset,
1949 fnIMultiLanguage2_GetRfc1766FromLcid,
1950 fnIMultiLanguage2_GetLcidFromRfc1766,
1951 fnIMultiLanguage2_EnumRfc1766,
1952 fnIMultiLanguage2_GetRfc1766Info,
1953 fnIMultiLanguage2_CreateConvertCharset,
1954 fnIMultiLanguage2_ConvertStringInIStream,
1955 fnIMultiLanguage2_ConvertStringToUnicodeEx,
1956 fnIMultiLanguage2_ConvertStringFromUnicodeEx,
1957 fnIMultiLanguage2_DetectCodepageInIStream,
1958 fnIMultiLanguage2_DetectInputCodepage,
1959 fnIMultiLanguage2_ValidateCodePage,
1960 fnIMultiLanguage2_GetCodePageDescription,
1961 fnIMultiLanguage2_IsCodePageInstallable,
1962 fnIMultiLanguage2_SetMimeDBSource,
1963 fnIMultiLanguage2_GetNumberOfScripts,
1964 fnIMultiLanguage2_EnumScripts,
1965 fnIMultiLanguage2_ValidateCodePageEx,
1968 static HRESULT MultiLanguage_create(IUnknown *pUnkOuter, LPVOID *ppObj)
1973 TRACE("Creating MultiLanguage object\n");
1976 return CLASS_E_NOAGGREGATION;
1978 mlang = HeapAlloc( GetProcessHeap(), 0, sizeof (MLang_impl) );
1979 mlang->vtbl_IMLangFontLink = &IMLangFontLink_vtbl;
1980 mlang->vtbl_IMultiLanguage = &IMultiLanguage_vtbl;
1981 mlang->vtbl_IMultiLanguage2 = &IMultiLanguage2_vtbl;
1983 mlang->total_cp = 0;
1984 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1985 mlang->total_cp += mlang_data[i].number_of_cp;
1987 /* do not enumerate unicode flavours */
1988 mlang->total_scripts = sizeof(mlang_data)/sizeof(mlang_data[0]) - 1;
1991 *ppObj = (LPVOID) mlang;
1992 TRACE("returning %p\n", mlang);
1996 /******************************************************************************/
1998 HRESULT WINAPI DllCanUnloadNow(void)
2004 HRESULT WINAPI GetGlobalFontLinkObject(void)