4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2003,2004 Mike McCormack
6 * Copyright 2004,2005 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);
53 static DWORD MLANG_tls_index; /* to store various per thead data */
56 * Under what circumstances HKEY_CLASSES_ROOT\MIME\Database\Codepage and
57 * HKEY_CLASSES_ROOT\MIME\Database\Charset are used?
62 const char *description;
65 const char *web_charset;
66 const char *header_charset;
67 const char *body_charset;
70 /* These data are based on the codepage info in libs/unicode/cpmap.pl */
71 /* FIXME: Add 28604 (Celtic), 28606 (Balkan) */
73 static const MIME_CP_INFO arabic_cp[] =
76 864, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
77 MIMECONTF_MIME_LATEST,
78 "ibm864", "ibm864", "ibm864" },
80 1006, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
81 MIMECONTF_MIME_LATEST,
82 "ibm1006", "ibm1006", "ibm1006" },
84 1256, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
85 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
86 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
87 "windows-1256", "windows-1256", "windows-1256" },
89 28596, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
90 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
91 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
92 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
93 "iso-8859-6", "iso-8859-6", "iso-8859-6" }
95 static const MIME_CP_INFO baltic_cp[] =
98 775, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
99 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
100 "ibm775", "ibm775", "ibm775" },
101 { "Baltic (Windows)",
102 1257, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
103 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
104 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
105 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
106 "windows-1257", "windows-1257", "windows-1257" },
108 28594, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
109 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
110 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
111 MIMECONTF_MIME_LATEST,
112 "iso-8859-4", "iso-8859-4", "iso-8859-4" },
114 28603, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
115 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
116 "iso-8859-13", "iso-8859-13", "iso-8859-13" }
118 static const MIME_CP_INFO chinese_simplified_cp[] =
120 { "Chinese Simplified (GB2312)",
121 936, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
122 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
123 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
124 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
125 "gb2312", "gb2312", "gb2312" }
127 static const MIME_CP_INFO chinese_traditional_cp[] =
129 { "Chinese Traditional (Big5)",
130 950, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
131 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
132 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
133 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
134 "big5", "big5", "big5" }
136 static const MIME_CP_INFO central_european_cp[] =
138 { "Central European (DOS)",
139 852, MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_BROWSER |
140 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
141 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
142 "ibm852", "ibm852", "ibm852" },
143 { "Central European (Windows)",
144 1250, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
145 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
146 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
147 MIMECONTF_MIME_LATEST,
148 "windows-1250", "windows-1250", "windows-1250" },
149 { "Central European (Mac)",
150 10029, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
151 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
152 "x-mac-ce", "x-mac-ce", "x-mac-ce" },
153 { "Central European (ISO)",
154 28592, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
155 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
156 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
157 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
158 "iso-8859-2", "iso-8859-2", "iso-8859-2" }
160 static const MIME_CP_INFO cyrillic_cp[] =
163 855, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
164 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
165 "ibm855", "ibm855", "ibm855" },
167 866, MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_BROWSER |
168 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
169 MIMECONTF_MIME_LATEST,
170 "cp866", "cp866", "cp866" },
171 #if 0 /* Windows has 20866 as an official code page for KOI8-R */
172 { "Cyrillic (KOI8-R)",
173 878, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
174 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
175 "koi8-r", "koi8-r", "koi8-r" },
177 { "Cyrillic (Windows)",
178 1251, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
179 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
180 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
181 "windows-1251", "windows-1251", "windows-1251" },
183 10007, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
184 MIMECONTF_MIME_LATEST,
185 "x-mac-cyrillic", "x-mac-cyrillic", "x-mac-cyrillic" },
186 { "Cyrillic (KOI8-R)",
187 20866, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
188 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
189 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
190 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
191 "koi8-r", "koi8-r", "koi8-r" },
192 { "Cyrillic (KOI8-U)",
193 21866, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
194 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
195 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
196 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
197 "koi8-u", "koi8-u", "koi8-u" },
199 28595, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
200 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
201 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
202 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
203 "iso-8859-5", "iso-8859-5", "iso-8859-5" }
205 static const MIME_CP_INFO greek_cp[] =
208 737, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
209 MIMECONTF_MIME_LATEST,
210 "ibm737", "ibm737", "ibm737" },
211 { "Greek, Modern (DOS)",
212 869, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
213 MIMECONTF_MIME_LATEST,
214 "ibm869", "ibm869", "ibm869" },
215 { "IBM EBCDIC (Greek Modern)",
216 875, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
217 MIMECONTF_MIME_LATEST,
218 "cp875", "cp875", "cp875" },
220 1253, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
221 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
222 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
223 "windows-1253", "windows-1253", "windows-1253" },
225 10006, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
226 MIMECONTF_MIME_LATEST,
227 "x-mac-greek", "x-mac-greek", "x-mac-greek" },
229 28597, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
230 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
231 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
232 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
233 "iso-8859-7", "iso-8859-7", "iso-8859-7" }
235 static const MIME_CP_INFO hebrew_cp[] =
238 424, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
239 MIMECONTF_MIME_LATEST,
240 "ibm424", "ibm424", "ibm424" },
242 856, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
243 MIMECONTF_MIME_LATEST,
244 "cp856", "cp856", "cp856" },
246 862, MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
247 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
248 MIMECONTF_MIME_LATEST,
249 "dos-862", "dos-862", "dos-862" },
250 { "Hebrew (Windows)",
251 1255, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
252 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
253 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
254 "windows-1255", "windows-1255", "windows-1255" },
255 { "Hebrew (ISO-Visual)",
256 28598, MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
257 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
258 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
259 "iso-8859-8", "iso-8859-8", "iso-8859-8" }
261 static const MIME_CP_INFO japanese_cp[] =
263 { "Japanese (Shift-JIS)",
264 932, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
265 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
266 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
267 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
268 "shift_jis", "iso-2022-jp", "iso-2022-jp" },
269 { "Japanese (JIS 0208-1990 and 0212-1990)",
270 20932, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
271 MIMECONTF_MIME_LATEST,
272 "euc-jp", "euc-jp", "euc-jp" }
274 static const MIME_CP_INFO korean_cp[] =
277 949, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
278 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
279 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
280 MIMECONTF_MIME_LATEST,
281 "ks_c_5601-1987", "ks_c_5601-1987", "ks_c_5601-1987" }
283 static const MIME_CP_INFO thai_cp[] =
286 874, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_MIME_LATEST,
287 "ibm-thai", "ibm-thai", "ibm-thai" }
289 static const MIME_CP_INFO turkish_cp[] =
292 857, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
293 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
294 "ibm857", "ibm857", "ibm857" },
295 { "IBM EBCDIC (Turkish Latin-5)",
296 1026, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
297 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
298 "ibm1026", "ibm1026", "ibm1026" },
299 { "Turkish (Windows)",
300 1254, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
301 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
302 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
303 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
304 "windows-1254", "windows-1254", "windows-1254" },
306 10081, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
307 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
308 "x-mac-turkish", "x-mac-turkish", "x-mac-turkish" },
310 28593, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
311 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_EXPORT | MIMECONTF_VALID |
312 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
313 "iso-8859-3", "iso-8859-3", "iso-8859-3" },
315 28599, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
316 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
317 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
318 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
319 "iso-8859-9", "iso-8859-9", "iso-8859-9" }
321 static const MIME_CP_INFO vietnamese_cp[] =
323 { "Vietnamese (Windows)",
324 1258, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
325 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
326 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
327 MIMECONTF_MIME_LATEST,
328 "windows-1258", "windows-1258", "windows-1258" }
330 static const MIME_CP_INFO western_cp[] =
332 { "IBM EBCDIC (US-Canada)",
333 37, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
334 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
335 "ibm037", "ibm037", "ibm037" },
336 { "OEM United States",
337 437, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
338 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
339 "ibm437", "ibm437", "ibm437" },
340 { "IBM EBCDIC (International)",
341 500, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
342 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
343 "ibm500", "ibm500", "ibm500" },
344 { "Western European (DOS)",
345 850, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
346 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
347 "ibm850", "ibm850", "ibm850" },
348 { "Portuguese (DOS)",
349 860, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
350 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
351 "ibm860", "ibm860", "ibm860" },
353 861, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
354 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
355 "ibm861", "ibm861", "ibm861" },
356 { "French Canadian (DOS)",
357 863, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
358 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
359 "ibm863", "ibm863", "ibm863" },
361 865, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
362 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
363 "ibm865", "ibm865", "ibm865" },
364 { "Western European (Windows)",
365 1252, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
366 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
367 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
368 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
369 "windows-1252", "windows-1252", "iso-8859-1" },
370 { "Western European (Mac)",
371 10000, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
372 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
373 "macintosh", "macintosh", "macintosh" },
375 10079, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
376 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
377 "x-mac-icelandic", "x-mac-icelandic", "x-mac-icelandic" },
378 { "Western European (ISO)",
379 28591, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
380 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
381 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
382 MIMECONTF_MIME_LATEST,
383 "iso-8859-1", "iso-8859-1", "iso-8859-1" },
385 28605, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
386 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
387 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
388 MIMECONTF_MIME_LATEST,
389 "iso-8859-15", "iso-8859-15", "iso-8859-15" }
391 static const MIME_CP_INFO unicode_cp[] =
394 CP_UNICODE, MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
395 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
396 MIMECONTF_VALID | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
397 MIMECONTF_MIME_LATEST,
398 "unicode", "unicode", "unicode" },
400 CP_UTF7, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
401 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_EXPORT | MIMECONTF_VALID |
402 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
403 "utf-7", "utf-7", "utf-7" },
405 CP_UTF8, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
406 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
407 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
408 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
409 "utf-8", "utf-8", "utf-8" }
412 static const struct mlang_data
414 const char *description;
415 UINT family_codepage;
417 const MIME_CP_INFO *mime_cp_info;
418 const char *fixed_font;
419 const char *proportional_font;
422 { "Arabic",1256,sizeof(arabic_cp)/sizeof(arabic_cp[0]),arabic_cp,
423 "Courier","Arial" }, /* FIXME */
424 { "Baltic",1257,sizeof(baltic_cp)/sizeof(baltic_cp[0]),baltic_cp,
425 "Courier","Arial" }, /* FIXME */
426 { "Chinese Simplified",936,sizeof(chinese_simplified_cp)/sizeof(chinese_simplified_cp[0]),chinese_simplified_cp,
427 "Courier","Arial" }, /* FIXME */
428 { "Chinese Traditional",950,sizeof(chinese_traditional_cp)/sizeof(chinese_traditional_cp[0]),chinese_traditional_cp,
429 "Courier","Arial" }, /* FIXME */
430 { "Central European",1250,sizeof(central_european_cp)/sizeof(central_european_cp[0]),central_european_cp,
431 "Courier","Arial" }, /* FIXME */
432 { "Cyrillic",1251,sizeof(cyrillic_cp)/sizeof(cyrillic_cp[0]),cyrillic_cp,
433 "Courier","Arial" }, /* FIXME */
434 { "Greek",1253,sizeof(greek_cp)/sizeof(greek_cp[0]),greek_cp,
435 "Courier","Arial" }, /* FIXME */
436 { "Hebrew",1255,sizeof(hebrew_cp)/sizeof(hebrew_cp[0]),hebrew_cp,
437 "Courier","Arial" }, /* FIXME */
438 { "Japanese",932,sizeof(japanese_cp)/sizeof(japanese_cp[0]),japanese_cp,
439 "Courier","Arial" }, /* FIXME */
440 { "Korean",949,sizeof(korean_cp)/sizeof(korean_cp[0]),korean_cp,
441 "Courier","Arial" }, /* FIXME */
442 { "Thai",874,sizeof(thai_cp)/sizeof(thai_cp[0]),thai_cp,
443 "Courier","Arial" }, /* FIXME */
444 { "Turkish",1254,sizeof(turkish_cp)/sizeof(turkish_cp[0]),turkish_cp,
445 "Courier","Arial" }, /* FIXME */
446 { "Vietnamese",1258,sizeof(vietnamese_cp)/sizeof(vietnamese_cp[0]),vietnamese_cp,
447 "Courier","Arial" }, /* FIXME */
448 { "Western European",1252,sizeof(western_cp)/sizeof(western_cp[0]),western_cp,
449 "Courier","Arial" }, /* FIXME */
450 { "Unicode",CP_UNICODE,sizeof(unicode_cp)/sizeof(unicode_cp[0]),unicode_cp,
451 "Courier","Arial" } /* FIXME */
454 static void fill_cp_info(const struct mlang_data *ml_data, UINT index, MIMECPINFO *mime_cp_info);
456 static LONG dll_count;
459 * Dll lifetime tracking declaration
461 static void LockModule(void)
463 InterlockedIncrement(&dll_count);
466 static void UnlockModule(void)
468 InterlockedDecrement(&dll_count);
471 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
474 case DLL_PROCESS_ATTACH:
475 MLANG_tls_index = TlsAlloc();
476 DisableThreadLibraryCalls(hInstDLL);
478 case DLL_PROCESS_DETACH:
479 TlsFree(MLANG_tls_index);
485 HRESULT WINAPI ConvertINetMultiByteToUnicode(
495 TRACE("%p %ld %s %p %p %p\n", pdwMode, dwEncoding,
496 debugstr_a(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
502 pcSrcSize = &src_len;
513 if (*pcSrcSize == -1)
514 *pcSrcSize = lstrlenW((LPCWSTR)pSrcStr);
515 *pcDstSize = min(*pcSrcSize, *pcDstSize);
516 *pcSrcSize *= sizeof(WCHAR);
518 memmove(pDstStr, pSrcStr, *pcDstSize * sizeof(WCHAR));
522 if (*pcSrcSize == -1)
523 *pcSrcSize = lstrlenA(pSrcStr);
526 *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, pDstStr, *pcDstSize);
528 *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, NULL, 0);
538 HRESULT WINAPI ConvertINetUnicodeToMultiByte(
549 TRACE("%p %ld %s %p %p %p\n", pdwMode, dwEncoding,
550 debugstr_w(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
556 pcSrcSize = &src_len;
567 if (*pcSrcSize == -1)
568 *pcSrcSize = lstrlenW(pSrcStr);
569 *pcDstSize = min(*pcSrcSize * sizeof(WCHAR), *pcDstSize);
571 memmove(pDstStr, pSrcStr, *pcDstSize);
575 if (*pcSrcSize == -1)
576 *pcSrcSize = lstrlenW(pSrcStr);
579 *pcDstSize = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize, pDstStr, *pcDstSize, NULL, NULL);
581 *pcDstSize = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize, NULL, 0, NULL, NULL);
592 HRESULT WINAPI ConvertINetString(
602 FIXME("%p %ld %ld %s %p %p %p: stub!\n", pdwMode, dwSrcEncoding, dwDstEncoding,
603 debugstr_a(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
607 static HRESULT GetFamilyCodePage(
609 UINT* puiFamilyCodePage)
613 TRACE("%u %p\n", uiCodePage, puiFamilyCodePage);
615 if (!puiFamilyCodePage) return S_FALSE;
617 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
619 for (n = 0; n < mlang_data[i].number_of_cp; n++)
621 if (mlang_data[i].mime_cp_info[n].cp == uiCodePage)
623 *puiFamilyCodePage = mlang_data[i].family_codepage;
632 HRESULT WINAPI IsConvertINetStringAvailable(
636 UINT src_family, dst_family;
638 TRACE("%ld %ld\n", dwSrcEncoding, dwDstEncoding);
640 if (GetFamilyCodePage(dwSrcEncoding, &src_family) != S_OK ||
641 GetFamilyCodePage(dwDstEncoding, &dst_family) != S_OK)
644 if (src_family == dst_family) return S_OK;
646 /* we can convert any codepage to/from unicode */
647 if (src_family == CP_UNICODE || dst_family == CP_UNICODE) return S_OK;
652 HRESULT WINAPI LcidToRfc1766A(
657 FIXME("%ld %s %u\n", Locale, pszRfc1766, nChar);
661 HRESULT WINAPI LcidToRfc1766W(
666 FIXME("%ld %p %u\n", Locale, pszRfc1766, nChar);
670 /******************************************************************************
674 IClassFactory ITF_IClassFactory;
677 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
680 struct object_creation_info
684 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
687 static const struct object_creation_info object_creation[] =
689 { &CLSID_CMultiLanguage, "CLSID_CMultiLanguage", MultiLanguage_create },
692 static HRESULT WINAPI
693 MLANGCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
695 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
697 TRACE("%s\n", debugstr_guid(riid) );
699 if (IsEqualGUID(riid, &IID_IUnknown)
700 || IsEqualGUID(riid, &IID_IClassFactory))
702 IClassFactory_AddRef(iface);
707 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
708 return E_NOINTERFACE;
711 static ULONG WINAPI MLANGCF_AddRef(LPCLASSFACTORY iface)
713 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
714 return InterlockedIncrement(&This->ref);
717 static ULONG WINAPI MLANGCF_Release(LPCLASSFACTORY iface)
719 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
721 ULONG ref = InterlockedDecrement(&This->ref);
725 TRACE("Destroying %p\n", This);
726 HeapFree(GetProcessHeap(), 0, This);
732 static HRESULT WINAPI MLANGCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
733 REFIID riid, LPVOID *ppobj)
735 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
739 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
742 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
743 if (SUCCEEDED(hres)) {
744 hres = IUnknown_QueryInterface(punk, riid, ppobj);
745 IUnknown_Release(punk);
747 TRACE("returning (%p) -> %lx\n", *ppobj, hres);
751 static HRESULT WINAPI MLANGCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
761 static const IClassFactoryVtbl MLANGCF_Vtbl =
763 MLANGCF_QueryInterface,
766 MLANGCF_CreateInstance,
770 /******************************************************************
771 * DllGetClassObject (MLANG.@)
773 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
776 IClassFactoryImpl *factory;
778 TRACE("%s %s %p\n",debugstr_guid(rclsid), debugstr_guid(iid), ppv);
780 if ( !IsEqualGUID( &IID_IClassFactory, iid )
781 && ! IsEqualGUID( &IID_IUnknown, iid) )
782 return E_NOINTERFACE;
784 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
786 if (IsEqualGUID(object_creation[i].clsid, rclsid))
790 if (i == sizeof(object_creation)/sizeof(object_creation[0]))
792 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
793 return CLASS_E_CLASSNOTAVAILABLE;
796 TRACE("Creating a class factory for %s\n",object_creation[i].szClassName);
798 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
799 if (factory == NULL) return E_OUTOFMEMORY;
801 factory->ITF_IClassFactory.lpVtbl = &MLANGCF_Vtbl;
804 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
806 *ppv = &(factory->ITF_IClassFactory);
808 TRACE("(%p) <- %p\n", ppv, &(factory->ITF_IClassFactory) );
814 /******************************************************************************/
816 typedef struct tagMLang_impl
818 const IMLangFontLinkVtbl *vtbl_IMLangFontLink;
819 const IMultiLanguageVtbl *vtbl_IMultiLanguage;
820 const IMultiLanguage2Vtbl *vtbl_IMultiLanguage2;
822 DWORD total_cp, total_scripts;
825 static ULONG WINAPI MLang_AddRef( MLang_impl* This)
827 return InterlockedIncrement(&This->ref);
830 static ULONG WINAPI MLang_Release( MLang_impl* This )
832 ULONG ref = InterlockedDecrement(&This->ref);
834 TRACE("%p ref = %ld\n", This, ref);
837 TRACE("Destroying %p\n", This);
838 HeapFree(GetProcessHeap(), 0, This);
845 static HRESULT WINAPI MLang_QueryInterface(
850 TRACE("%p -> %s\n", This, debugstr_guid(riid) );
852 if (IsEqualGUID(riid, &IID_IUnknown)
853 || IsEqualGUID(riid, &IID_IMLangCodePages)
854 || IsEqualGUID(riid, &IID_IMLangFontLink))
857 TRACE("Returning IID_IMLangFontLink %p ref = %ld\n", This, This->ref);
858 *ppvObject = &(This->vtbl_IMLangFontLink);
862 if (IsEqualGUID(riid, &IID_IMultiLanguage) )
865 TRACE("Returning IID_IMultiLanguage %p ref = %ld\n", This, This->ref);
866 *ppvObject = &(This->vtbl_IMultiLanguage);
870 if (IsEqualGUID(riid, &IID_IMultiLanguage2) )
873 *ppvObject = &(This->vtbl_IMultiLanguage2);
874 TRACE("Returning IID_IMultiLanguage2 %p ref = %ld\n", This, This->ref);
878 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
879 return E_NOINTERFACE;
882 /******************************************************************************/
884 typedef struct tagEnumCodePage_impl
886 const IEnumCodePageVtbl *vtbl_IEnumCodePage;
892 static HRESULT WINAPI fnIEnumCodePage_QueryInterface(
893 IEnumCodePage* iface,
897 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
899 TRACE("%p -> %s\n", This, debugstr_guid(riid) );
901 if (IsEqualGUID(riid, &IID_IUnknown)
902 || IsEqualGUID(riid, &IID_IEnumCodePage))
904 IEnumCodePage_AddRef(iface);
905 TRACE("Returning IID_IEnumCodePage %p ref = %ld\n", This, This->ref);
906 *ppvObject = &(This->vtbl_IEnumCodePage);
910 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
911 return E_NOINTERFACE;
914 static ULONG WINAPI fnIEnumCodePage_AddRef(
915 IEnumCodePage* iface)
917 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
918 return InterlockedIncrement(&This->ref);
921 static ULONG WINAPI fnIEnumCodePage_Release(
922 IEnumCodePage* iface)
924 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
925 ULONG ref = InterlockedDecrement(&This->ref);
927 TRACE("%p ref = %ld\n", This, ref);
930 TRACE("Destroying %p\n", This);
931 HeapFree(GetProcessHeap(), 0, This->cpinfo);
932 HeapFree(GetProcessHeap(), 0, This);
938 static HRESULT WINAPI fnIEnumCodePage_Clone(
939 IEnumCodePage* iface,
940 IEnumCodePage** ppEnum)
942 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
943 FIXME("%p %p\n", This, ppEnum);
947 static HRESULT WINAPI fnIEnumCodePage_Next(
948 IEnumCodePage* iface,
955 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
956 TRACE("%p %lu %p %p\n", This, celt, rgelt, pceltFetched);
958 if (!pceltFetched) return S_FALSE;
961 if (!rgelt) return S_FALSE;
963 if (This->pos + celt > This->total)
964 celt = This->total - This->pos;
966 if (!celt) return S_FALSE;
968 memcpy(rgelt, This->cpinfo + This->pos, celt * sizeof(MIMECPINFO));
969 *pceltFetched = celt;
972 for (i = 0; i < celt; i++)
974 TRACE("#%lu: %08lx %u %u %s %s %s %s %s %s %d\n",
975 i, rgelt[i].dwFlags, rgelt[i].uiCodePage,
976 rgelt[i].uiFamilyCodePage,
977 wine_dbgstr_w(rgelt[i].wszDescription),
978 wine_dbgstr_w(rgelt[i].wszWebCharset),
979 wine_dbgstr_w(rgelt[i].wszHeaderCharset),
980 wine_dbgstr_w(rgelt[i].wszBodyCharset),
981 wine_dbgstr_w(rgelt[i].wszFixedWidthFont),
982 wine_dbgstr_w(rgelt[i].wszProportionalFont),
983 rgelt[i].bGDICharset);
988 static HRESULT WINAPI fnIEnumCodePage_Reset(
989 IEnumCodePage* iface)
991 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
998 static HRESULT WINAPI fnIEnumCodePage_Skip(
999 IEnumCodePage* iface,
1002 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
1003 TRACE("%p %lu\n", This, celt);
1005 if (celt >= This->total) return S_FALSE;
1011 static const IEnumCodePageVtbl IEnumCodePage_vtbl =
1013 fnIEnumCodePage_QueryInterface,
1014 fnIEnumCodePage_AddRef,
1015 fnIEnumCodePage_Release,
1016 fnIEnumCodePage_Clone,
1017 fnIEnumCodePage_Next,
1018 fnIEnumCodePage_Reset,
1019 fnIEnumCodePage_Skip
1022 static HRESULT EnumCodePage_create( MLang_impl* mlang, DWORD grfFlags,
1023 LANGID LangId, IEnumCodePage** ppEnumCodePage )
1025 EnumCodePage_impl *ecp;
1029 TRACE("%p, %08lx, %04x, %p\n", mlang, grfFlags, LangId, ppEnumCodePage);
1031 if (!grfFlags) /* enumerate internal data base of encodings */
1032 grfFlags = MIMECONTF_MIME_LATEST;
1034 ecp = HeapAlloc( GetProcessHeap(), 0, sizeof (EnumCodePage_impl) );
1035 ecp->vtbl_IEnumCodePage = &IEnumCodePage_vtbl;
1039 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1041 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1043 if (mlang_data[i].mime_cp_info[n].flags & grfFlags)
1048 ecp->cpinfo = HeapAlloc(GetProcessHeap(), 0,
1049 sizeof(MIMECPINFO) * ecp->total);
1050 cpinfo = ecp->cpinfo;
1052 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1054 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1056 if (mlang_data[i].mime_cp_info[n].flags & grfFlags)
1057 fill_cp_info(&mlang_data[i], n, cpinfo++);
1061 TRACE("enumerated %ld codepages with flags %08lx\n", ecp->total, grfFlags);
1063 *ppEnumCodePage = (IEnumCodePage*) ecp;
1068 /******************************************************************************/
1070 typedef struct tagEnumScript_impl
1072 const IEnumScriptVtbl *vtbl_IEnumScript;
1074 SCRIPTINFO *script_info;
1078 static HRESULT WINAPI fnIEnumScript_QueryInterface(
1083 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1085 TRACE("%p -> %s\n", This, debugstr_guid(riid) );
1087 if (IsEqualGUID(riid, &IID_IUnknown)
1088 || IsEqualGUID(riid, &IID_IEnumScript))
1090 IEnumScript_AddRef(iface);
1091 TRACE("Returning IID_IEnumScript %p ref = %ld\n", This, This->ref);
1092 *ppvObject = &(This->vtbl_IEnumScript);
1096 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
1097 return E_NOINTERFACE;
1100 static ULONG WINAPI fnIEnumScript_AddRef(
1103 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1104 return InterlockedIncrement(&This->ref);
1107 static ULONG WINAPI fnIEnumScript_Release(
1110 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1111 ULONG ref = InterlockedDecrement(&This->ref);
1113 TRACE("%p ref = %ld\n", This, ref);
1116 TRACE("Destroying %p\n", This);
1117 HeapFree(GetProcessHeap(), 0, This);
1123 static HRESULT WINAPI fnIEnumScript_Clone(
1125 IEnumScript** ppEnum)
1127 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1128 FIXME("%p %p: stub!\n", This, ppEnum);
1132 static HRESULT WINAPI fnIEnumScript_Next(
1136 ULONG* pceltFetched)
1138 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1139 TRACE("%p %lu %p %p\n", This, celt, rgelt, pceltFetched);
1141 if (!pceltFetched || !rgelt) return E_FAIL;
1145 if (This->pos + celt > This->total)
1146 celt = This->total - This->pos;
1148 if (!celt) return S_FALSE;
1150 memcpy(rgelt, This->script_info + This->pos, celt * sizeof(SCRIPTINFO));
1151 *pceltFetched = celt;
1157 static HRESULT WINAPI fnIEnumScript_Reset(
1160 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1161 TRACE("%p\n", This);
1167 static HRESULT WINAPI fnIEnumScript_Skip(
1171 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1172 TRACE("%p %lu\n", This, celt);
1174 if (celt >= This->total) return S_FALSE;
1180 static const IEnumScriptVtbl IEnumScript_vtbl =
1182 fnIEnumScript_QueryInterface,
1183 fnIEnumScript_AddRef,
1184 fnIEnumScript_Release,
1185 fnIEnumScript_Clone,
1187 fnIEnumScript_Reset,
1191 static HRESULT EnumScript_create( MLang_impl* mlang, DWORD dwFlags,
1192 LANGID LangId, IEnumScript** ppEnumScript )
1194 EnumScript_impl *es;
1197 TRACE("%p, %08lx, %04x, %p: stub!\n", mlang, dwFlags, LangId, ppEnumScript);
1199 if (!dwFlags) /* enumerate all available scripts */
1200 dwFlags = SCRIPTCONTF_SCRIPT_USER | SCRIPTCONTF_SCRIPT_HIDE | SCRIPTCONTF_SCRIPT_SYSTEM;
1202 es = HeapAlloc( GetProcessHeap(), 0, sizeof (EnumScript_impl) );
1203 es->vtbl_IEnumScript = &IEnumScript_vtbl;
1206 /* do not enumerate unicode flavours */
1207 es->total = sizeof(mlang_data)/sizeof(mlang_data[0]) - 1;
1208 es->script_info = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPTINFO) * es->total);
1210 for (i = 0; i < es->total; i++)
1212 es->script_info[i].ScriptId = i;
1213 es->script_info[i].uiCodePage = mlang_data[i].family_codepage;
1214 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].description, -1,
1215 es->script_info[i].wszDescription, MAX_SCRIPT_NAME);
1216 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].fixed_font, -1,
1217 es->script_info[i].wszFixedWidthFont, MAX_MIMEFACE_NAME);
1218 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].proportional_font, -1,
1219 es->script_info[i].wszProportionalFont, MAX_MIMEFACE_NAME);
1222 TRACE("enumerated %ld scripts with flags %08lx\n", es->total, dwFlags);
1224 *ppEnumScript = (IEnumScript *)es;
1229 /******************************************************************************/
1231 static HRESULT WINAPI fnIMLangFontLink_QueryInterface(
1232 IMLangFontLink* iface,
1236 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
1237 return MLang_QueryInterface( This, riid, ppvObject );
1240 static ULONG WINAPI fnIMLangFontLink_AddRef(
1241 IMLangFontLink* iface)
1243 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
1244 return MLang_AddRef( This );
1247 static ULONG WINAPI fnIMLangFontLink_Release(
1248 IMLangFontLink* iface)
1250 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
1251 return MLang_Release( This );
1254 static HRESULT WINAPI fnIMLangFontLink_GetCharCodePages(
1255 IMLangFontLink* iface,
1257 DWORD* pdwCodePages)
1263 static HRESULT WINAPI fnIMLangFontLink_GetStrCodePages(
1264 IMLangFontLink* iface,
1265 const WCHAR* pszSrc,
1267 DWORD dwPriorityCodePages,
1268 DWORD* pdwCodePages,
1269 long* pcchCodePages)
1275 static HRESULT WINAPI fnIMLangFontLink_CodePageToCodePages(
1276 IMLangFontLink* iface,
1278 DWORD* pdwCodePages)
1280 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
1284 TRACE("(%p) Seeking %u\n",This, uCodePage);
1285 memset(&cs, 0, sizeof(cs));
1287 rc = TranslateCharsetInfo((DWORD*)uCodePage, &cs, TCI_SRCCODEPAGE);
1291 *pdwCodePages = cs.fs.fsCsb[0];
1292 TRACE("resulting CodePages 0x%lx\n",*pdwCodePages);
1295 TRACE("CodePage Not Found\n");
1300 static HRESULT WINAPI fnIMLangFontLink_CodePagesToCodePage(
1301 IMLangFontLink* iface,
1303 UINT uDefaultCodePage,
1306 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
1307 DWORD mask = 0x00000000;
1312 TRACE("(%p) scanning 0x%lx default page %u\n",This, dwCodePages,
1315 *puCodePage = 0x00000000;
1317 rc = TranslateCharsetInfo((DWORD*)uDefaultCodePage, &cs, TCI_SRCCODEPAGE);
1319 if (rc && (dwCodePages & cs.fs.fsCsb[0]))
1321 TRACE("Found Default Codepage\n");
1322 *puCodePage = uDefaultCodePage;
1327 for (i = 0; i < 32; i++)
1331 if (dwCodePages & mask)
1336 rc = TranslateCharsetInfo((DWORD*)Csb, &cs, TCI_SRCFONTSIG);
1340 TRACE("Falling back to least significant found CodePage %u\n",
1342 *puCodePage = cs.ciACP;
1347 TRACE("no codepage found\n");
1351 static HRESULT WINAPI fnIMLangFontLink_GetFontCodePages(
1352 IMLangFontLink* iface,
1355 DWORD* pdwCodePages)
1358 FONTSIGNATURE fontsig;
1359 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
1361 TRACE("(%p)\n",This);
1363 old_font = SelectObject(hDC,hFont);
1364 GetTextCharsetInfo(hDC,&fontsig, 0);
1365 SelectObject(hDC,old_font);
1367 *pdwCodePages = fontsig.fsCsb[0];
1368 TRACE("CodePages is 0x%lx\n",fontsig.fsCsb[0]);
1373 static HRESULT WINAPI fnIMLangFontLink_MapFont(
1374 IMLangFontLink* iface,
1384 static HRESULT WINAPI fnIMLangFontLink_ReleaseFont(
1385 IMLangFontLink* iface,
1392 static HRESULT WINAPI fnIMLangFontLink_ResetFontMapping(
1393 IMLangFontLink* iface)
1400 static const IMLangFontLinkVtbl IMLangFontLink_vtbl =
1402 fnIMLangFontLink_QueryInterface,
1403 fnIMLangFontLink_AddRef,
1404 fnIMLangFontLink_Release,
1405 fnIMLangFontLink_GetCharCodePages,
1406 fnIMLangFontLink_GetStrCodePages,
1407 fnIMLangFontLink_CodePageToCodePages,
1408 fnIMLangFontLink_CodePagesToCodePage,
1409 fnIMLangFontLink_GetFontCodePages,
1410 fnIMLangFontLink_MapFont,
1411 fnIMLangFontLink_ReleaseFont,
1412 fnIMLangFontLink_ResetFontMapping,
1415 /******************************************************************************/
1417 static HRESULT WINAPI fnIMultiLanguage_QueryInterface(
1418 IMultiLanguage* iface,
1422 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1423 return MLang_QueryInterface( This, riid, ppvObject );
1426 static ULONG WINAPI fnIMultiLanguage_AddRef( IMultiLanguage* iface )
1428 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1429 return IMLangFontLink_AddRef( ((IMLangFontLink*)This) );
1432 static ULONG WINAPI fnIMultiLanguage_Release( IMultiLanguage* iface )
1434 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1435 return IMLangFontLink_Release( ((IMLangFontLink*)This) );
1438 static HRESULT WINAPI fnIMultiLanguage_GetNumberOfCodePageInfo(
1439 IMultiLanguage* iface,
1446 static HRESULT WINAPI fnIMultiLanguage_GetCodePageInfo(
1447 IMultiLanguage* iface,
1449 PMIMECPINFO pCodePageInfo)
1455 static HRESULT WINAPI fnIMultiLanguage_GetFamilyCodePage(
1456 IMultiLanguage* iface,
1458 UINT* puiFamilyCodePage)
1460 return GetFamilyCodePage(uiCodePage, puiFamilyCodePage);
1463 static HRESULT WINAPI fnIMultiLanguage_EnumCodePages(
1464 IMultiLanguage* iface,
1466 IEnumCodePage** ppEnumCodePage)
1468 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1469 TRACE("%p %08lx %p\n", This, grfFlags, ppEnumCodePage);
1471 return EnumCodePage_create( This, grfFlags, 0, ppEnumCodePage );
1474 static HRESULT WINAPI fnIMultiLanguage_GetCharsetInfo(
1475 IMultiLanguage* iface,
1477 PMIMECSETINFO pCharsetInfo)
1483 static HRESULT WINAPI fnIMultiLanguage_IsConvertible(
1484 IMultiLanguage* iface,
1485 DWORD dwSrcEncoding,
1486 DWORD dwDstEncoding)
1488 return IsConvertINetStringAvailable(dwSrcEncoding, dwDstEncoding);
1491 static HRESULT WINAPI fnIMultiLanguage_ConvertString(
1492 IMultiLanguage* iface,
1494 DWORD dwSrcEncoding,
1495 DWORD dwDstEncoding,
1501 return ConvertINetString(pdwMode, dwSrcEncoding, dwDstEncoding,
1502 (LPCSTR)pSrcStr, (LPINT)pcSrcSize, (LPSTR)pDstStr, (LPINT)pcDstSize);
1505 static HRESULT WINAPI fnIMultiLanguage_ConvertStringToUnicode(
1506 IMultiLanguage* iface,
1514 return ConvertINetMultiByteToUnicode(pdwMode, dwEncoding,
1515 (LPCSTR)pSrcStr, (LPINT)pcSrcSize, pDstStr, (LPINT)pcDstSize);
1518 static HRESULT WINAPI fnIMultiLanguage_ConvertStringFromUnicode(
1519 IMultiLanguage* iface,
1527 return ConvertINetUnicodeToMultiByte(pdwMode, dwEncoding,
1528 pSrcStr, (LPINT)pcSrcSize, pDstStr, (LPINT)pcDstSize);
1531 static HRESULT WINAPI fnIMultiLanguage_ConvertStringReset(
1532 IMultiLanguage* iface)
1538 static HRESULT WINAPI fnIMultiLanguage_GetRfc1766FromLcid(
1539 IMultiLanguage* iface,
1547 static HRESULT WINAPI fnIMultiLanguage_GetLcidFromRfc1766(
1548 IMultiLanguage* iface,
1556 /******************************************************************************/
1558 typedef struct tagEnumRfc1766_impl
1560 const IEnumRfc1766Vtbl *vtbl_IEnumRfc1766;
1566 static HRESULT WINAPI fnIEnumRfc1766_QueryInterface(
1567 IEnumRfc1766 *iface,
1571 ICOM_THIS_MULTI(EnumRfc1766_impl, vtbl_IEnumRfc1766, iface);
1573 TRACE("%p -> %s\n", This, debugstr_guid(riid) );
1575 if (IsEqualGUID(riid, &IID_IUnknown)
1576 || IsEqualGUID(riid, &IID_IEnumRfc1766))
1578 IEnumRfc1766_AddRef(iface);
1579 TRACE("Returning IID_IEnumRfc1766 %p ref = %ld\n", This, This->ref);
1580 *ppvObject = &(This->vtbl_IEnumRfc1766);
1584 WARN("(%p) -> (%s,%p), not found\n",This,debugstr_guid(riid),ppvObject);
1585 return E_NOINTERFACE;
1588 static ULONG WINAPI fnIEnumRfc1766_AddRef(
1589 IEnumRfc1766 *iface)
1591 ICOM_THIS_MULTI(EnumRfc1766_impl, vtbl_IEnumRfc1766, iface);
1592 return InterlockedIncrement(&This->ref);
1595 static ULONG WINAPI fnIEnumRfc1766_Release(
1596 IEnumRfc1766 *iface)
1598 ICOM_THIS_MULTI(EnumRfc1766_impl, vtbl_IEnumRfc1766, iface);
1599 ULONG ref = InterlockedDecrement(&This->ref);
1601 TRACE("%p ref = %ld\n", This, ref);
1604 TRACE("Destroying %p\n", This);
1605 HeapFree(GetProcessHeap(), 0, This->info);
1606 HeapFree(GetProcessHeap(), 0, This);
1611 static HRESULT WINAPI fnIEnumRfc1766_Clone(
1612 IEnumRfc1766 *iface,
1613 IEnumRfc1766 **ppEnum)
1615 ICOM_THIS_MULTI(EnumRfc1766_impl, vtbl_IEnumRfc1766, iface);
1616 FIXME("%p %p\n", This, ppEnum);
1620 static HRESULT WINAPI fnIEnumRfc1766_Next(
1621 IEnumRfc1766 *iface,
1624 ULONG *pceltFetched)
1628 ICOM_THIS_MULTI(EnumRfc1766_impl, vtbl_IEnumRfc1766, iface);
1629 TRACE("%p %lu %p %p\n", This, celt, rgelt, pceltFetched);
1631 if (!pceltFetched) return S_FALSE;
1634 if (!rgelt) return S_FALSE;
1636 if (This->pos + celt > This->total)
1637 celt = This->total - This->pos;
1639 if (!celt) return S_FALSE;
1641 memcpy(rgelt, This->info + This->pos, celt * sizeof(RFC1766INFO));
1642 *pceltFetched = celt;
1645 for (i = 0; i < celt; i++)
1647 TRACE("#%lu: %08lx %s %s\n",
1649 wine_dbgstr_w(rgelt[i].wszRfc1766),
1650 wine_dbgstr_w(rgelt[i].wszLocaleName));
1655 static HRESULT WINAPI fnIEnumRfc1766_Reset(
1656 IEnumRfc1766 *iface)
1658 ICOM_THIS_MULTI(EnumRfc1766_impl, vtbl_IEnumRfc1766, iface);
1659 TRACE("%p\n", This);
1665 static HRESULT WINAPI fnIEnumRfc1766_Skip(
1666 IEnumRfc1766 *iface,
1669 ICOM_THIS_MULTI(EnumRfc1766_impl, vtbl_IEnumRfc1766, iface);
1670 TRACE("%p %lu\n", This, celt);
1672 if (celt >= This->total) return S_FALSE;
1678 static const IEnumRfc1766Vtbl IEnumRfc1766_vtbl =
1680 fnIEnumRfc1766_QueryInterface,
1681 fnIEnumRfc1766_AddRef,
1682 fnIEnumRfc1766_Release,
1683 fnIEnumRfc1766_Clone,
1684 fnIEnumRfc1766_Next,
1685 fnIEnumRfc1766_Reset,
1689 struct enum_locales_data
1692 DWORD total, allocated;
1695 static BOOL CALLBACK enum_locales_proc(LPWSTR locale)
1699 struct enum_locales_data *data = TlsGetValue(MLANG_tls_index);
1702 TRACE("%s\n", debugstr_w(locale));
1704 if (data->total >= data->allocated)
1706 data->allocated += 32;
1707 data->info = HeapReAlloc(GetProcessHeap(), 0, data->info, data->allocated * sizeof(RFC1766INFO));
1708 if (!data->info) return FALSE;
1711 info = &data->info[data->total];
1713 info->lcid = strtolW(locale, &end, 16);
1714 if (*end) /* invalid number */
1717 info->wszRfc1766[0] = 0;
1718 n = GetLocaleInfoW(info->lcid, LOCALE_SISO639LANGNAME, info->wszRfc1766, MAX_RFC1766_NAME);
1719 if (n && n < MAX_RFC1766_NAME)
1721 info->wszRfc1766[n - 1] = '-';
1722 GetLocaleInfoW(info->lcid, LOCALE_SISO3166CTRYNAME, info->wszRfc1766 + n, MAX_RFC1766_NAME - n);
1723 LCMapStringW(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, info->wszRfc1766 + n, -1, info->wszRfc1766 + n, MAX_RFC1766_NAME - n);
1725 info->wszLocaleName[0] = 0;
1726 GetLocaleInfoW(info->lcid, LOCALE_SLANGUAGE, info->wszLocaleName, MAX_LOCALE_NAME);
1727 TRACE("ISO639: %s SLANGUAGE: %s\n", wine_dbgstr_w(info->wszRfc1766), wine_dbgstr_w(info->wszLocaleName));
1734 static HRESULT EnumRfc1766_create(MLang_impl* mlang, LANGID LangId,
1735 IEnumRfc1766 **ppEnum)
1737 EnumRfc1766_impl *rfc;
1738 struct enum_locales_data data;
1740 TRACE("%p, %04x, %p\n", mlang, LangId, ppEnum);
1742 rfc = HeapAlloc( GetProcessHeap(), 0, sizeof(EnumRfc1766_impl) );
1743 rfc->vtbl_IEnumRfc1766 = &IEnumRfc1766_vtbl;
1749 data.allocated = 32;
1750 data.info = HeapAlloc(GetProcessHeap(), 0, data.allocated * sizeof(RFC1766INFO));
1751 if (!data.info) return S_FALSE;
1753 TlsSetValue(MLANG_tls_index, &data);
1754 EnumSystemLocalesW(enum_locales_proc, 0/*LOCALE_SUPPORTED*/);
1755 TlsSetValue(MLANG_tls_index, NULL);
1757 TRACE("enumerated %ld rfc1766 structures\n", data.total);
1759 if (!data.total) return FALSE;
1761 rfc->info = data.info;
1762 rfc->total = data.total;
1764 *ppEnum = (IEnumRfc1766 *)rfc;
1768 static HRESULT WINAPI fnIMultiLanguage_EnumRfc1766(
1769 IMultiLanguage *iface,
1770 IEnumRfc1766 **ppEnumRfc1766)
1772 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1773 TRACE("%p %p\n", This, ppEnumRfc1766);
1775 return EnumRfc1766_create(This, 0, ppEnumRfc1766);
1778 /******************************************************************************/
1780 static HRESULT WINAPI fnIMultiLanguage_GetRfc1766Info(
1781 IMultiLanguage* iface,
1783 PRFC1766INFO pRfc1766Info)
1789 static HRESULT WINAPI fnIMultiLanguage_CreateConvertCharset(
1790 IMultiLanguage* iface,
1794 IMLangConvertCharset** ppMLangConvertCharset)
1800 static const IMultiLanguageVtbl IMultiLanguage_vtbl =
1802 fnIMultiLanguage_QueryInterface,
1803 fnIMultiLanguage_AddRef,
1804 fnIMultiLanguage_Release,
1805 fnIMultiLanguage_GetNumberOfCodePageInfo,
1806 fnIMultiLanguage_GetCodePageInfo,
1807 fnIMultiLanguage_GetFamilyCodePage,
1808 fnIMultiLanguage_EnumCodePages,
1809 fnIMultiLanguage_GetCharsetInfo,
1810 fnIMultiLanguage_IsConvertible,
1811 fnIMultiLanguage_ConvertString,
1812 fnIMultiLanguage_ConvertStringToUnicode,
1813 fnIMultiLanguage_ConvertStringFromUnicode,
1814 fnIMultiLanguage_ConvertStringReset,
1815 fnIMultiLanguage_GetRfc1766FromLcid,
1816 fnIMultiLanguage_GetLcidFromRfc1766,
1817 fnIMultiLanguage_EnumRfc1766,
1818 fnIMultiLanguage_GetRfc1766Info,
1819 fnIMultiLanguage_CreateConvertCharset,
1823 /******************************************************************************/
1825 static HRESULT WINAPI fnIMultiLanguage2_QueryInterface(
1826 IMultiLanguage2* iface,
1830 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1831 return MLang_QueryInterface( This, riid, ppvObject );
1834 static ULONG WINAPI fnIMultiLanguage2_AddRef( IMultiLanguage2* iface )
1836 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1837 return MLang_AddRef( This );
1840 static ULONG WINAPI fnIMultiLanguage2_Release( IMultiLanguage2* iface )
1842 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1843 return MLang_Release( This );
1846 static HRESULT WINAPI fnIMultiLanguage2_GetNumberOfCodePageInfo(
1847 IMultiLanguage2* iface,
1850 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1851 TRACE("%p, %p\n", This, pcCodePage);
1853 if (!pcCodePage) return S_FALSE;
1855 *pcCodePage = This->total_cp;
1859 static void fill_cp_info(const struct mlang_data *ml_data, UINT index, MIMECPINFO *mime_cp_info)
1863 if (TranslateCharsetInfo((DWORD *)ml_data->family_codepage, &csi, TCI_SRCCODEPAGE))
1864 mime_cp_info->bGDICharset = csi.ciCharset;
1866 mime_cp_info->bGDICharset = DEFAULT_CHARSET;
1868 mime_cp_info->dwFlags = ml_data->mime_cp_info[index].flags;
1869 mime_cp_info->uiCodePage = ml_data->mime_cp_info[index].cp;
1870 mime_cp_info->uiFamilyCodePage = ml_data->family_codepage;
1871 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].description, -1,
1872 mime_cp_info->wszDescription, sizeof(mime_cp_info->wszDescription)/sizeof(WCHAR));
1873 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].web_charset, -1,
1874 mime_cp_info->wszWebCharset, sizeof(mime_cp_info->wszWebCharset)/sizeof(WCHAR));
1875 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].header_charset, -1,
1876 mime_cp_info->wszHeaderCharset, sizeof(mime_cp_info->wszHeaderCharset)/sizeof(WCHAR));
1877 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].body_charset, -1,
1878 mime_cp_info->wszBodyCharset, sizeof(mime_cp_info->wszBodyCharset)/sizeof(WCHAR));
1880 MultiByteToWideChar(CP_ACP, 0, ml_data->fixed_font, -1,
1881 mime_cp_info->wszFixedWidthFont, sizeof(mime_cp_info->wszFixedWidthFont)/sizeof(WCHAR));
1882 MultiByteToWideChar(CP_ACP, 0, ml_data->proportional_font, -1,
1883 mime_cp_info->wszProportionalFont, sizeof(mime_cp_info->wszProportionalFont)/sizeof(WCHAR));
1885 TRACE("%08lx %u %u %s %s %s %s %s %s %d\n",
1886 mime_cp_info->dwFlags, mime_cp_info->uiCodePage,
1887 mime_cp_info->uiFamilyCodePage,
1888 wine_dbgstr_w(mime_cp_info->wszDescription),
1889 wine_dbgstr_w(mime_cp_info->wszWebCharset),
1890 wine_dbgstr_w(mime_cp_info->wszHeaderCharset),
1891 wine_dbgstr_w(mime_cp_info->wszBodyCharset),
1892 wine_dbgstr_w(mime_cp_info->wszFixedWidthFont),
1893 wine_dbgstr_w(mime_cp_info->wszProportionalFont),
1894 mime_cp_info->bGDICharset);
1897 static HRESULT WINAPI fnIMultiLanguage2_GetCodePageInfo(
1898 IMultiLanguage2* iface,
1901 PMIMECPINFO pCodePageInfo)
1905 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1906 TRACE("%p, %u, %04x, %p\n", This, uiCodePage, LangId, pCodePageInfo);
1908 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1910 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1912 if (mlang_data[i].mime_cp_info[n].cp == uiCodePage)
1914 fill_cp_info(&mlang_data[i], n, pCodePageInfo);
1923 static HRESULT WINAPI fnIMultiLanguage2_GetFamilyCodePage(
1924 IMultiLanguage2* iface,
1926 UINT* puiFamilyCodePage)
1928 return GetFamilyCodePage(uiCodePage, puiFamilyCodePage);
1931 static HRESULT WINAPI fnIMultiLanguage2_EnumCodePages(
1932 IMultiLanguage2* iface,
1935 IEnumCodePage** ppEnumCodePage)
1937 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1938 TRACE("%p %08lx %04x %p\n", This, grfFlags, LangId, ppEnumCodePage);
1940 return EnumCodePage_create( This, grfFlags, LangId, ppEnumCodePage );
1943 static HRESULT WINAPI fnIMultiLanguage2_GetCharsetInfo(
1944 IMultiLanguage2* iface,
1946 PMIMECSETINFO pCharsetInfo)
1950 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1951 TRACE("%p %s %p\n", This, debugstr_w(Charset), pCharsetInfo);
1953 if (!pCharsetInfo) return E_FAIL;
1955 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1957 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1959 WCHAR csetW[MAX_MIMECSET_NAME];
1961 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].mime_cp_info[n].web_charset, -1, csetW, MAX_MIMECSET_NAME);
1962 if (!lstrcmpiW(Charset, csetW))
1964 pCharsetInfo->uiCodePage = mlang_data[i].family_codepage;
1965 pCharsetInfo->uiInternetEncoding = mlang_data[i].mime_cp_info[n].cp;
1966 strcpyW(pCharsetInfo->wszCharset, csetW);
1973 * Since we do not support charsets like iso-2022-jp and do not have
1974 * them in our database as a primary (web_charset) encoding this loop
1975 * does an attempt to 'approximate' charset name by header_charset.
1977 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1979 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1981 WCHAR csetW[MAX_MIMECSET_NAME];
1983 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].mime_cp_info[n].header_charset, -1, csetW, MAX_MIMECSET_NAME);
1984 if (!lstrcmpiW(Charset, csetW))
1986 pCharsetInfo->uiCodePage = mlang_data[i].family_codepage;
1987 pCharsetInfo->uiInternetEncoding = mlang_data[i].mime_cp_info[n].cp;
1988 strcpyW(pCharsetInfo->wszCharset, csetW);
1997 static HRESULT WINAPI fnIMultiLanguage2_IsConvertible(
1998 IMultiLanguage2* iface,
1999 DWORD dwSrcEncoding,
2000 DWORD dwDstEncoding)
2002 return IsConvertINetStringAvailable(dwSrcEncoding, dwDstEncoding);
2005 static HRESULT WINAPI fnIMultiLanguage2_ConvertString(
2006 IMultiLanguage2* iface,
2008 DWORD dwSrcEncoding,
2009 DWORD dwDstEncoding,
2015 return ConvertINetString(pdwMode, dwSrcEncoding, dwDstEncoding,
2016 (LPCSTR)pSrcStr, (LPINT)pcSrcSize, (LPSTR)pDstStr, (LPINT)pcDstSize);
2019 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringToUnicode(
2020 IMultiLanguage2* iface,
2028 return ConvertINetMultiByteToUnicode(pdwMode, dwEncoding,
2029 pSrcStr, (LPINT)pcSrcSize, pDstStr, (LPINT)pcDstSize);
2032 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringFromUnicode(
2033 IMultiLanguage2* iface,
2041 return ConvertINetUnicodeToMultiByte(pdwMode, dwEncoding,
2042 pSrcStr, (LPINT)pcSrcSize, pDstStr, (LPINT)pcDstSize);
2045 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringReset(
2046 IMultiLanguage2* iface)
2052 static HRESULT WINAPI fnIMultiLanguage2_GetRfc1766FromLcid(
2053 IMultiLanguage2* iface,
2061 static HRESULT WINAPI fnIMultiLanguage2_GetLcidFromRfc1766(
2062 IMultiLanguage2* iface,
2070 static HRESULT WINAPI fnIMultiLanguage2_EnumRfc1766(
2071 IMultiLanguage2* iface,
2073 IEnumRfc1766** ppEnumRfc1766)
2075 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
2076 TRACE("%p %p\n", This, ppEnumRfc1766);
2078 return EnumRfc1766_create(This, LangId, ppEnumRfc1766);
2081 static HRESULT WINAPI fnIMultiLanguage2_GetRfc1766Info(
2082 IMultiLanguage2* iface,
2085 PRFC1766INFO pRfc1766Info)
2091 static HRESULT WINAPI fnIMultiLanguage2_CreateConvertCharset(
2092 IMultiLanguage2* iface,
2096 IMLangConvertCharset** ppMLangConvertCharset)
2102 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringInIStream(
2103 IMultiLanguage2* iface,
2107 DWORD dwSrcEncoding,
2108 DWORD dwDstEncoding,
2116 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringToUnicodeEx(
2117 IMultiLanguage2* iface,
2131 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringFromUnicodeEx(
2132 IMultiLanguage2* This,
2146 static HRESULT WINAPI fnIMultiLanguage2_DetectCodepageInIStream(
2147 IMultiLanguage2* iface,
2149 DWORD dwPrefWinCodePage,
2151 DetectEncodingInfo* lpEncoding,
2158 static HRESULT WINAPI fnIMultiLanguage2_DetectInputCodepage(
2159 IMultiLanguage2* iface,
2161 DWORD dwPrefWinCodePage,
2164 DetectEncodingInfo* lpEncoding,
2171 static HRESULT WINAPI fnIMultiLanguage2_ValidateCodePage(
2172 IMultiLanguage2* iface,
2176 FIXME("%u, %p\n", uiCodePage, hwnd);
2180 static HRESULT WINAPI fnIMultiLanguage2_GetCodePageDescription(
2181 IMultiLanguage2* iface,
2184 LPWSTR lpWideCharStr,
2187 FIXME("%u, %04lx, %p, %d\n", uiCodePage, lcid, lpWideCharStr, cchWideChar);
2191 static HRESULT WINAPI fnIMultiLanguage2_IsCodePageInstallable(
2192 IMultiLanguage2* iface,
2195 FIXME("%u\n", uiCodePage);
2199 static HRESULT WINAPI fnIMultiLanguage2_SetMimeDBSource(
2200 IMultiLanguage2* iface,
2207 static HRESULT WINAPI fnIMultiLanguage2_GetNumberOfScripts(
2208 IMultiLanguage2* iface,
2211 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
2212 TRACE("%p %p\n", This, pnScripts);
2214 if (!pnScripts) return S_FALSE;
2216 *pnScripts = This->total_scripts;
2220 static HRESULT WINAPI fnIMultiLanguage2_EnumScripts(
2221 IMultiLanguage2* iface,
2224 IEnumScript** ppEnumScript)
2226 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
2227 TRACE("%p %08lx %04x %p\n", This, dwFlags, LangId, ppEnumScript);
2229 return EnumScript_create( This, dwFlags, LangId, ppEnumScript );
2232 static HRESULT WINAPI fnIMultiLanguage2_ValidateCodePageEx(
2233 IMultiLanguage2* iface,
2236 DWORD dwfIODControl)
2238 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
2239 FIXME("%p %u %p %08lx: stub!\n", This, uiCodePage, hwnd, dwfIODControl);
2244 static const IMultiLanguage2Vtbl IMultiLanguage2_vtbl =
2246 fnIMultiLanguage2_QueryInterface,
2247 fnIMultiLanguage2_AddRef,
2248 fnIMultiLanguage2_Release,
2249 fnIMultiLanguage2_GetNumberOfCodePageInfo,
2250 fnIMultiLanguage2_GetCodePageInfo,
2251 fnIMultiLanguage2_GetFamilyCodePage,
2252 fnIMultiLanguage2_EnumCodePages,
2253 fnIMultiLanguage2_GetCharsetInfo,
2254 fnIMultiLanguage2_IsConvertible,
2255 fnIMultiLanguage2_ConvertString,
2256 fnIMultiLanguage2_ConvertStringToUnicode,
2257 fnIMultiLanguage2_ConvertStringFromUnicode,
2258 fnIMultiLanguage2_ConvertStringReset,
2259 fnIMultiLanguage2_GetRfc1766FromLcid,
2260 fnIMultiLanguage2_GetLcidFromRfc1766,
2261 fnIMultiLanguage2_EnumRfc1766,
2262 fnIMultiLanguage2_GetRfc1766Info,
2263 fnIMultiLanguage2_CreateConvertCharset,
2264 fnIMultiLanguage2_ConvertStringInIStream,
2265 fnIMultiLanguage2_ConvertStringToUnicodeEx,
2266 fnIMultiLanguage2_ConvertStringFromUnicodeEx,
2267 fnIMultiLanguage2_DetectCodepageInIStream,
2268 fnIMultiLanguage2_DetectInputCodepage,
2269 fnIMultiLanguage2_ValidateCodePage,
2270 fnIMultiLanguage2_GetCodePageDescription,
2271 fnIMultiLanguage2_IsCodePageInstallable,
2272 fnIMultiLanguage2_SetMimeDBSource,
2273 fnIMultiLanguage2_GetNumberOfScripts,
2274 fnIMultiLanguage2_EnumScripts,
2275 fnIMultiLanguage2_ValidateCodePageEx,
2278 static HRESULT MultiLanguage_create(IUnknown *pUnkOuter, LPVOID *ppObj)
2283 TRACE("Creating MultiLanguage object\n");
2286 return CLASS_E_NOAGGREGATION;
2288 mlang = HeapAlloc( GetProcessHeap(), 0, sizeof (MLang_impl) );
2289 mlang->vtbl_IMLangFontLink = &IMLangFontLink_vtbl;
2290 mlang->vtbl_IMultiLanguage = &IMultiLanguage_vtbl;
2291 mlang->vtbl_IMultiLanguage2 = &IMultiLanguage2_vtbl;
2293 mlang->total_cp = 0;
2294 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
2295 mlang->total_cp += mlang_data[i].number_of_cp;
2297 /* do not enumerate unicode flavours */
2298 mlang->total_scripts = sizeof(mlang_data)/sizeof(mlang_data[0]) - 1;
2301 *ppObj = (LPVOID) mlang;
2302 TRACE("returning %p\n", mlang);
2309 /******************************************************************************/
2311 HRESULT WINAPI DllCanUnloadNow(void)
2313 return dll_count == 0 ? S_OK : S_FALSE;
2316 HRESULT WINAPI GetGlobalFontLinkObject(void)