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
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(mlang);
46 #define CP_UNICODE 1200
48 static HRESULT MultiLanguage_create(IUnknown *pUnkOuter, LPVOID *ppObj);
51 * Under what circumstances HKEY_CLASSES_ROOT\MIME\Database\Codepage and
52 * HKEY_CLASSES_ROOT\MIME\Database\Charset are used?
59 const char *web_charset;
60 const char *header_charset;
61 const char *body_charset;
64 /* These data are based on the codepage info in libs/unicode/cpmap.pl */
65 /* FIXME: Add 28604 (Celtic), 28606 (Balkan) */
67 static const MIME_CP_INFO arabic_cp[] =
69 { 864, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
70 MIMECONTF_MIME_LATEST,
71 "ibm864", "ibm864", "ibm864" },
72 { 1006, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
73 MIMECONTF_MIME_LATEST,
74 "ibm1006", "ibm1006", "ibm1006" },
75 { 1256, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
76 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
77 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
78 "windows-1256", "windows-1256", "windows-1256" },
79 { 28596, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
80 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
81 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
82 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
83 "iso-8859-6", "iso-8859-6", "iso-8859-6" }
85 static const MIME_CP_INFO baltic_cp[] =
87 { 775, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
88 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
89 "ibm775", "ibm775", "ibm775" },
90 { 1257, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
91 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
92 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
93 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
94 "windows-1257", "windows-1257", "windows-1257" },
95 { 28594, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
96 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
97 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
98 MIMECONTF_MIME_LATEST,
99 "iso-8859-4", "iso-8859-4", "iso-8859-4" },
100 { 28603, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
101 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
102 "iso-8859-13", "iso-8859-13", "iso-8859-13" }
104 static const MIME_CP_INFO chinese_simplified_cp[] =
106 { 936, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
107 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
108 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
109 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
110 "gb2312", "gb2312", "gb2312" }
112 static const MIME_CP_INFO chinese_traditional_cp[] =
114 { 950, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
115 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
116 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
117 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
118 "big5", "big5", "big5" }
120 static const MIME_CP_INFO central_european_cp[] =
122 { 852, MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_BROWSER |
123 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
124 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
125 "ibm852", "ibm852", "ibm852" },
126 { 1250, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
127 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
128 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
129 MIMECONTF_MIME_LATEST,
130 "windows-1250", "windows-1250", "windows-1250" },
131 { 10029, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
132 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
133 "x-mac-ce", "x-mac-ce", "x-mac-ce" },
134 { 28592, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
135 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
136 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
137 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
138 "iso-8859-2", "iso-8859-2", "iso-8859-2" }
140 static const MIME_CP_INFO cyrillic_cp[] =
142 { 855, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
143 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
144 "ibm855", "ibm855", "ibm855" },
145 { 866, MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_BROWSER |
146 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
147 MIMECONTF_MIME_LATEST,
148 "cp866", "cp866", "cp866" },
149 { 878, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
150 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
151 "koi8-r", "koi8-r", "koi8-r" },
152 { 1251, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
153 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
154 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
155 "windows-1251", "windows-1251", "windows-1251" },
156 { 10007, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
157 MIMECONTF_MIME_LATEST,
158 "x-mac-cyrillic", "x-mac-cyrillic", "x-mac-cyrillic" },
159 { 20866, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
160 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
161 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
162 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
163 "koi8-r", "koi8-r", "koi8-r" },
164 { 28595, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
165 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
166 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
167 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
168 "iso-8859-5", "iso-8859-5", "iso-8859-5" }
170 static const MIME_CP_INFO greek_cp[] =
172 { 737, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
173 MIMECONTF_MIME_LATEST,
174 "ibm737", "ibm737", "ibm737" },
175 { 869, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
176 MIMECONTF_MIME_LATEST,
177 "ibm869", "ibm869", "ibm869" },
178 { 875, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
179 MIMECONTF_MIME_LATEST,
180 "cp875", "cp875", "cp875" },
181 { 1253, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
182 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
183 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
184 "windows-1253", "windows-1253", "windows-1253" },
185 { 10006, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
186 MIMECONTF_MIME_LATEST,
187 "x-mac-greek", "x-mac-greek", "x-mac-greek" },
188 { 28597, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
189 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
190 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
191 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
192 "iso-8859-7", "iso-8859-7", "iso-8859-7" }
194 static const MIME_CP_INFO hebrew_cp[] =
196 { 424, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
197 MIMECONTF_MIME_LATEST,
198 "ibm424", "ibm424", "ibm424" },
199 { 856, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
200 MIMECONTF_MIME_LATEST,
201 "cp856", "cp856", "cp856" },
202 { 862, MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
203 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
204 MIMECONTF_MIME_LATEST,
205 "dos-862", "dos-862", "dos-862" },
206 { 1255, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
207 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
208 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
209 "windows-1255", "windows-1255", "windows-1255" },
210 { 28598, MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
211 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
212 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
213 "iso-8859-8", "iso-8859-8", "iso-8859-8" }
215 static const MIME_CP_INFO japanese_cp[] =
217 { 932, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
218 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
219 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
220 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
221 "shift_jis", "iso-2022-jp", "iso-2022-jp" },
222 { 20932, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
223 MIMECONTF_MIME_LATEST,
224 "euc-jp", "euc-jp", "euc-jp" }
226 static const MIME_CP_INFO korean_cp[] =
228 { 949, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
229 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
230 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
231 MIMECONTF_MIME_LATEST,
232 "ks_c_5601-1987", "ks_c_5601-1987", "ks_c_5601-1987" }
234 static const MIME_CP_INFO thai_cp[] =
236 { 874, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_MIME_LATEST,
237 "ibm-thai", "ibm-thai", "ibm-thai" }
239 static const MIME_CP_INFO turkish_cp[] =
241 { 857, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
242 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
243 "ibm857", "ibm857", "ibm857" },
244 { 1026, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
245 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
246 "ibm1026", "ibm1026", "ibm1026" },
247 { 1254, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
248 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
249 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
250 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
251 "windows-1254", "windows-1254", "windows-1254" },
252 { 10081, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
253 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
254 "x-mac-turkish", "x-mac-turkish", "x-mac-turkish" },
255 { 28593, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
256 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_EXPORT | MIMECONTF_VALID |
257 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
258 "iso-8859-3", "iso-8859-3", "iso-8859-3" },
259 { 28599, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
260 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
261 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
262 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
263 "iso-8859-9", "iso-8859-9", "iso-8859-9" }
265 static const MIME_CP_INFO vietnamese_cp[] =
267 { 1258, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
268 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
269 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
270 MIMECONTF_MIME_LATEST,
271 "windows-1258", "windows-1258", "windows-1258" }
273 static const MIME_CP_INFO western_cp[] =
275 { 37, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
276 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
277 "ibm037", "ibm037", "ibm037" },
278 { 437, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
279 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
280 "ibm437", "ibm437", "ibm437" },
281 { 500, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
282 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
283 "ibm500", "ibm500", "ibm500" },
284 { 850, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
285 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
286 "ibm850", "ibm850", "ibm850" },
287 { 860, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
288 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
289 "ibm860", "ibm860", "ibm860" },
290 { 861, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
291 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
292 "ibm861", "ibm861", "ibm861" },
293 { 863, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
294 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
295 "ibm863", "ibm863", "ibm863" },
296 { 865, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
297 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
298 "ibm865", "ibm865", "ibm865" },
299 { 1252, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
300 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
301 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
302 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
303 "windows-1252", "windows-1252", "iso-8859-1" },
304 { 10000, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
305 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
306 "macintosh", "macintosh", "macintosh" },
307 { 10079, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
308 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
309 "x-mac-icelandic", "x-mac-icelandic", "x-mac-icelandic" },
310 { 28591, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
311 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
312 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
313 MIMECONTF_MIME_LATEST,
314 "iso-8859-1", "iso-8859-1", "iso-8859-1" },
315 { 28605, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
316 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
317 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
318 MIMECONTF_MIME_LATEST,
319 "iso-8859-15", "iso-8859-15", "iso-8859-15" }
321 static const MIME_CP_INFO unicode_cp[] =
323 { CP_UNICODE, MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
324 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
325 MIMECONTF_VALID | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
326 MIMECONTF_MIME_LATEST,
327 "unicode", "unicode", "unicode" },
328 { CP_UTF7, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
329 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_EXPORT | MIMECONTF_VALID |
330 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
331 "utf-7", "utf-7", "utf-7" },
332 { CP_UTF8, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
333 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
334 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
335 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
336 "utf-8", "utf-8", "utf-8" }
339 static const struct mlang_data
342 UINT family_codepage;
344 const MIME_CP_INFO *mime_cp_info;
345 const char *fixed_font; /* FIXME: Add */
346 const char *proportional_font; /* FIXME: Add */
349 { MAKELANGID(LANG_ARABIC,SUBLANG_DEFAULT),1256,sizeof(arabic_cp)/sizeof(arabic_cp[0]),arabic_cp },
351 { MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT),1257,sizeof(baltic_cp)/sizeof(baltic_cp[0]),baltic_cp },
352 { MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED),936,sizeof(chinese_simplified_cp)/sizeof(chinese_simplified_cp[0]),chinese_simplified_cp },
353 { MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_TRADITIONAL),950,sizeof(chinese_traditional_cp)/sizeof(chinese_traditional_cp[0]),chinese_traditional_cp },
355 { MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT),1250,sizeof(central_european_cp)/sizeof(central_european_cp[0]),central_european_cp },
356 { MAKELANGID(LANG_RUSSIAN,SUBLANG_DEFAULT),1251,sizeof(cyrillic_cp)/sizeof(cyrillic_cp[0]),cyrillic_cp },
357 { MAKELANGID(LANG_GREEK,SUBLANG_DEFAULT),1253,sizeof(greek_cp)/sizeof(greek_cp[0]),greek_cp },
358 { MAKELANGID(LANG_HEBREW,SUBLANG_DEFAULT),1255,sizeof(hebrew_cp)/sizeof(hebrew_cp[0]),hebrew_cp },
359 { MAKELANGID(LANG_JAPANESE,SUBLANG_DEFAULT),932,sizeof(japanese_cp)/sizeof(japanese_cp[0]),japanese_cp },
360 { MAKELANGID(LANG_KOREAN,SUBLANG_DEFAULT),949,sizeof(korean_cp)/sizeof(korean_cp[0]),korean_cp },
361 { MAKELANGID(LANG_THAI,SUBLANG_DEFAULT),874,sizeof(thai_cp)/sizeof(thai_cp[0]),thai_cp },
362 { MAKELANGID(LANG_TURKISH,SUBLANG_DEFAULT),1254,sizeof(turkish_cp)/sizeof(turkish_cp[0]),turkish_cp },
363 { MAKELANGID(LANG_VIETNAMESE,SUBLANG_DEFAULT),1258,sizeof(vietnamese_cp)/sizeof(vietnamese_cp[0]),vietnamese_cp },
364 { MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT),1252,sizeof(western_cp)/sizeof(western_cp[0]),western_cp },
366 { MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT),CP_UNICODE,sizeof(unicode_cp)/sizeof(unicode_cp[0]),unicode_cp }
369 static void fill_cp_info(const struct mlang_data *ml_data, UINT index, MIMECPINFO *mime_cp_info);
371 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
374 case DLL_PROCESS_ATTACH:
375 DisableThreadLibraryCalls(hInstDLL);
377 case DLL_PROCESS_DETACH:
383 /******************************************************************************
387 IClassFactory ITF_IClassFactory;
390 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
393 struct object_creation_info
397 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
400 static const struct object_creation_info object_creation[] =
402 { &CLSID_CMultiLanguage, "CLSID_CMultiLanguage", MultiLanguage_create },
405 static HRESULT WINAPI
406 MLANGCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
408 ICOM_THIS(IClassFactoryImpl,iface);
410 TRACE("%s\n", debugstr_guid(riid) );
412 if (IsEqualGUID(riid, &IID_IUnknown)
413 || IsEqualGUID(riid, &IID_IClassFactory))
415 IClassFactory_AddRef(iface);
420 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
421 return E_NOINTERFACE;
424 static ULONG WINAPI MLANGCF_AddRef(LPCLASSFACTORY iface) {
425 ICOM_THIS(IClassFactoryImpl,iface);
426 return ++(This->ref);
429 static ULONG WINAPI MLANGCF_Release(LPCLASSFACTORY iface) {
430 ICOM_THIS(IClassFactoryImpl,iface);
432 ULONG ref = --This->ref;
436 TRACE("Destroying %p\n", This);
437 HeapFree(GetProcessHeap(), 0, This);
443 static HRESULT WINAPI MLANGCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
444 REFIID riid, LPVOID *ppobj) {
445 ICOM_THIS(IClassFactoryImpl,iface);
449 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
451 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
456 hres = IUnknown_QueryInterface(punk, riid, ppobj);
461 IUnknown_Release(punk);
462 TRACE("returning (%p) -> %lx\n", *ppobj, hres);
466 static HRESULT WINAPI MLANGCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
467 ICOM_THIS(IClassFactoryImpl,iface);
468 FIXME("(%p)->(%d),stub!\n",This,dolock);
472 static ICOM_VTABLE(IClassFactory) MLANGCF_Vtbl =
474 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
475 MLANGCF_QueryInterface,
478 MLANGCF_CreateInstance,
482 HRESULT WINAPI MLANG_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
485 IClassFactoryImpl *factory;
487 TRACE("%s %s %p\n",debugstr_guid(rclsid), debugstr_guid(iid), ppv);
489 if ( !IsEqualGUID( &IID_IClassFactory, iid )
490 && ! IsEqualGUID( &IID_IUnknown, iid) )
491 return E_NOINTERFACE;
493 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
495 if (IsEqualGUID(object_creation[i].clsid, rclsid))
499 if (i == sizeof(object_creation)/sizeof(object_creation[0]))
501 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
502 return CLASS_E_CLASSNOTAVAILABLE;
505 TRACE("Creating a class factory for %s\n",object_creation[i].szClassName);
507 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
508 if (factory == NULL) return E_OUTOFMEMORY;
510 factory->ITF_IClassFactory.lpVtbl = &MLANGCF_Vtbl;
513 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
515 *ppv = &(factory->ITF_IClassFactory);
517 TRACE("(%p) <- %p\n", ppv, &(factory->ITF_IClassFactory) );
523 /******************************************************************************/
525 typedef struct tagMLang_impl
527 ICOM_VTABLE(IMLangFontLink) *vtbl_IMLangFontLink;
528 ICOM_VTABLE(IMultiLanguage) *vtbl_IMultiLanguage;
529 ICOM_VTABLE(IMultiLanguage2) *vtbl_IMultiLanguage2;
534 static ULONG WINAPI MLang_AddRef( MLang_impl* This)
536 return ++(This->ref);
539 static ULONG WINAPI MLang_Release( MLang_impl* This )
541 ULONG ref = --This->ref;
543 TRACE("%p ref = %ld\n", This, ref);
546 TRACE("Destroying %p\n", This);
547 HeapFree(GetProcessHeap(), 0, This);
553 static HRESULT WINAPI MLang_QueryInterface(
558 TRACE("%p -> %s\n", This, debugstr_guid(riid) );
560 if (IsEqualGUID(riid, &IID_IUnknown)
561 || IsEqualGUID(riid, &IID_IMLangCodePages)
562 || IsEqualGUID(riid, &IID_IMLangFontLink))
565 TRACE("Returning IID_IMLangFontLink %p ref = %ld\n", This, This->ref);
566 *ppvObject = &(This->vtbl_IMLangFontLink);
570 if (IsEqualGUID(riid, &IID_IMultiLanguage) )
573 TRACE("Returning IID_IMultiLanguage %p ref = %ld\n", This, This->ref);
574 *ppvObject = &(This->vtbl_IMultiLanguage);
578 if (IsEqualGUID(riid, &IID_IMultiLanguage2) )
581 *ppvObject = &(This->vtbl_IMultiLanguage2);
582 TRACE("Returning IID_IMultiLanguage2 %p ref = %ld\n", This, This->ref);
586 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
587 return E_NOINTERFACE;
590 /******************************************************************************/
592 typedef struct tagEnumCodePage_impl
594 ICOM_VTABLE(IEnumCodePage) *vtbl_IEnumCodePage;
600 static HRESULT WINAPI fnIEnumCodePage_QueryInterface(
601 IEnumCodePage* iface,
605 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
607 TRACE("%p -> %s\n", This, debugstr_guid(riid) );
609 if (IsEqualGUID(riid, &IID_IUnknown)
610 || IsEqualGUID(riid, &IID_IEnumCodePage))
612 IEnumCodePage_AddRef(iface);
613 TRACE("Returning IID_IEnumCodePage %p ref = %ld\n", This, This->ref);
614 *ppvObject = &(This->vtbl_IEnumCodePage);
618 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
619 return E_NOINTERFACE;
622 static ULONG WINAPI fnIEnumCodePage_AddRef(
623 IEnumCodePage* iface)
625 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
626 return ++(This->ref);
629 static ULONG WINAPI fnIEnumCodePage_Release(
630 IEnumCodePage* iface)
632 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
633 ULONG ref = --This->ref;
635 TRACE("%p ref = %ld\n", This, ref);
638 TRACE("Destroying %p\n", This);
639 HeapFree(GetProcessHeap(), 0, This->cpinfo);
640 HeapFree(GetProcessHeap(), 0, This);
646 static HRESULT WINAPI fnIEnumCodePage_Clone(
647 IEnumCodePage* iface,
648 IEnumCodePage** ppEnum)
650 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
651 FIXME("%p %p\n", This, ppEnum);
655 static HRESULT WINAPI fnIEnumCodePage_Next(
656 IEnumCodePage* iface,
661 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
662 TRACE("%p %lu %p %p\n", This, celt, rgelt, pceltFetched);
664 if (!pceltFetched) return S_FALSE;
667 if (!rgelt) return S_FALSE;
669 if (This->pos + celt > This->total)
670 celt = This->total - This->pos;
672 if (!celt) return S_FALSE;
674 memcpy(rgelt, This->cpinfo + This->pos, celt * sizeof(MIMECPINFO));
675 *pceltFetched = celt;
681 static HRESULT WINAPI fnIEnumCodePage_Reset(
682 IEnumCodePage* iface)
684 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
691 static HRESULT WINAPI fnIEnumCodePage_Skip(
692 IEnumCodePage* iface,
695 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
696 TRACE("%p %lu\n", This, celt);
698 if (celt >= This->total) return S_FALSE;
700 This->pos = celt; /* FIXME: should be += ?? */
704 static ICOM_VTABLE(IEnumCodePage) IEnumCodePage_vtbl =
706 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
707 fnIEnumCodePage_QueryInterface,
708 fnIEnumCodePage_AddRef,
709 fnIEnumCodePage_Release,
710 fnIEnumCodePage_Clone,
711 fnIEnumCodePage_Next,
712 fnIEnumCodePage_Reset,
716 static HRESULT EnumCodePage_create( MLang_impl* mlang, DWORD grfFlags,
717 LANGID LangId, IEnumCodePage** ppEnumCodePage )
719 EnumCodePage_impl *ecp;
723 TRACE("%p, %08lx, %04x, %p\n", mlang, grfFlags, LangId, ppEnumCodePage);
725 if (!grfFlags) /* enumerate internal data base of encodings */
726 grfFlags = MIMECONTF_MIME_LATEST;
728 ecp = HeapAlloc( GetProcessHeap(), 0, sizeof (EnumCodePage_impl) );
729 ecp->vtbl_IEnumCodePage = &IEnumCodePage_vtbl;
732 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
734 for (n = 0; n < mlang_data[i].number_of_cp; n++)
736 if (mlang_data[i].mime_cp_info[n].flags & grfFlags)
741 ecp->cpinfo = HeapAlloc(GetProcessHeap(), 0,
742 sizeof(MIMECPINFO) * ecp->total);
743 cpinfo = ecp->cpinfo;
745 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
747 for (n = 0; n < mlang_data[i].number_of_cp; n++)
749 if (mlang_data[i].mime_cp_info[n].flags & grfFlags)
750 fill_cp_info(&mlang_data[i], n, cpinfo++);
754 TRACE("enumerated %ld codepages with flags %08lx\n", ecp->total, grfFlags);
756 *ppEnumCodePage = (IEnumCodePage*) ecp;
761 /******************************************************************************/
763 static HRESULT WINAPI fnIMLangFontLink_QueryInterface(
764 IMLangFontLink* iface,
768 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
769 return MLang_QueryInterface( This, riid, ppvObject );
772 static ULONG WINAPI fnIMLangFontLink_AddRef(
773 IMLangFontLink* iface)
775 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
776 return MLang_AddRef( This );
779 static ULONG WINAPI fnIMLangFontLink_Release(
780 IMLangFontLink* iface)
782 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
783 return MLang_Release( This );
786 static HRESULT WINAPI fnIMLangFontLink_GetCharCodePages(
787 IMLangFontLink* iface,
795 static HRESULT WINAPI fnIMLangFontLink_GetStrCodePages(
796 IMLangFontLink* iface,
799 DWORD dwPriorityCodePages,
807 static HRESULT WINAPI fnIMLangFontLink_CodePageToCodePages(
808 IMLangFontLink* iface,
816 static HRESULT WINAPI fnIMLangFontLink_CodePagesToCodePage(
817 IMLangFontLink* iface,
819 UINT uDefaultCodePage,
826 static HRESULT WINAPI fnIMLangFontLink_GetFontCodePages(
827 IMLangFontLink* iface,
836 static HRESULT WINAPI fnIMLangFontLink_MapFont(
837 IMLangFontLink* iface,
847 static HRESULT WINAPI fnIMLangFontLink_ReleaseFont(
848 IMLangFontLink* iface,
855 static HRESULT WINAPI fnIMLangFontLink_ResetFontMapping(
856 IMLangFontLink* iface)
863 static ICOM_VTABLE(IMLangFontLink) IMLangFontLink_vtbl =
865 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
866 fnIMLangFontLink_QueryInterface,
867 fnIMLangFontLink_AddRef,
868 fnIMLangFontLink_Release,
869 fnIMLangFontLink_GetCharCodePages,
870 fnIMLangFontLink_GetStrCodePages,
871 fnIMLangFontLink_CodePageToCodePages,
872 fnIMLangFontLink_CodePagesToCodePage,
873 fnIMLangFontLink_GetFontCodePages,
874 fnIMLangFontLink_MapFont,
875 fnIMLangFontLink_ReleaseFont,
876 fnIMLangFontLink_ResetFontMapping,
879 /******************************************************************************/
881 static HRESULT WINAPI fnIMultiLanguage_QueryInterface(
882 IMultiLanguage* iface,
886 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
887 return MLang_QueryInterface( This, riid, ppvObject );
890 static ULONG WINAPI fnIMultiLanguage_AddRef( IMultiLanguage* iface )
892 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
893 return IMLangFontLink_AddRef( ((IMLangFontLink*)This) );
896 static ULONG WINAPI fnIMultiLanguage_Release( IMultiLanguage* iface )
898 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
899 return IMLangFontLink_Release( ((IMLangFontLink*)This) );
902 static HRESULT WINAPI fnIMultiLanguage_GetNumberOfCodePageInfo(
903 IMultiLanguage* iface,
910 static HRESULT WINAPI fnIMultiLanguage_GetCodePageInfo(
911 IMultiLanguage* iface,
913 PMIMECPINFO pCodePageInfo)
919 static HRESULT WINAPI fnIMultiLanguage_GetFamilyCodePage(
920 IMultiLanguage* iface,
922 UINT* puiFamilyCodePage)
928 static HRESULT WINAPI fnIMultiLanguage_EnumCodePages(
929 IMultiLanguage* iface,
931 IEnumCodePage** ppEnumCodePage)
933 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
934 TRACE("%p %08lx %p\n", This, grfFlags, ppEnumCodePage);
936 return EnumCodePage_create( This, grfFlags, 0, ppEnumCodePage );
939 static HRESULT WINAPI fnIMultiLanguage_GetCharsetInfo(
940 IMultiLanguage* iface,
942 PMIMECSETINFO pCharsetInfo)
948 static HRESULT WINAPI fnIMultiLanguage_IsConvertible(
949 IMultiLanguage* iface,
957 static HRESULT WINAPI fnIMultiLanguage_ConvertString(
958 IMultiLanguage* iface,
971 static HRESULT WINAPI fnIMultiLanguage_ConvertStringToUnicode(
972 IMultiLanguage* iface,
984 static HRESULT WINAPI fnIMultiLanguage_ConvertStringFromUnicode(
985 IMultiLanguage* iface,
997 static HRESULT WINAPI fnIMultiLanguage_ConvertStringReset(
998 IMultiLanguage* iface)
1004 static HRESULT WINAPI fnIMultiLanguage_GetRfc1766FromLcid(
1005 IMultiLanguage* iface,
1013 static HRESULT WINAPI fnIMultiLanguage_GetLcidFromRfc1766(
1014 IMultiLanguage* iface,
1022 static HRESULT WINAPI fnIMultiLanguage_EnumRfc1766(
1023 IMultiLanguage* iface,
1024 IEnumRfc1766** ppEnumRfc1766)
1030 static HRESULT WINAPI fnIMultiLanguage_GetRfc1766Info(
1031 IMultiLanguage* iface,
1033 PRFC1766INFO pRfc1766Info)
1039 static HRESULT WINAPI fnIMultiLanguage_CreateConvertCharset(
1040 IMultiLanguage* iface,
1044 IMLangConvertCharset** ppMLangConvertCharset)
1050 static ICOM_VTABLE(IMultiLanguage) IMultiLanguage_vtbl =
1052 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1053 fnIMultiLanguage_QueryInterface,
1054 fnIMultiLanguage_AddRef,
1055 fnIMultiLanguage_Release,
1056 fnIMultiLanguage_GetNumberOfCodePageInfo,
1057 fnIMultiLanguage_GetCodePageInfo,
1058 fnIMultiLanguage_GetFamilyCodePage,
1059 fnIMultiLanguage_EnumCodePages,
1060 fnIMultiLanguage_GetCharsetInfo,
1061 fnIMultiLanguage_IsConvertible,
1062 fnIMultiLanguage_ConvertString,
1063 fnIMultiLanguage_ConvertStringToUnicode,
1064 fnIMultiLanguage_ConvertStringFromUnicode,
1065 fnIMultiLanguage_ConvertStringReset,
1066 fnIMultiLanguage_GetRfc1766FromLcid,
1067 fnIMultiLanguage_GetLcidFromRfc1766,
1068 fnIMultiLanguage_EnumRfc1766,
1069 fnIMultiLanguage_GetRfc1766Info,
1070 fnIMultiLanguage_CreateConvertCharset,
1074 /******************************************************************************/
1076 static HRESULT WINAPI fnIMultiLanguage2_QueryInterface(
1077 IMultiLanguage2* iface,
1081 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1082 return MLang_QueryInterface( This, riid, ppvObject );
1085 static ULONG WINAPI fnIMultiLanguage2_AddRef( IMultiLanguage2* iface )
1087 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1088 return MLang_AddRef( This );
1091 static ULONG WINAPI fnIMultiLanguage2_Release( IMultiLanguage2* iface )
1093 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1094 return MLang_Release( This );
1097 static HRESULT WINAPI fnIMultiLanguage2_GetNumberOfCodePageInfo(
1098 IMultiLanguage2* iface,
1101 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1102 TRACE("%p, %p\n", This, pcCodePage);
1104 if (!pcCodePage) return S_FALSE;
1106 *pcCodePage = This->total;
1110 static void fill_cp_info(const struct mlang_data *ml_data, UINT index, MIMECPINFO *mime_cp_info)
1116 if (TranslateCharsetInfo((DWORD *)ml_data->family_codepage, &csi, TCI_SRCCODEPAGE))
1117 mime_cp_info->bGDICharset = csi.ciCharset;
1119 mime_cp_info->bGDICharset = DEFAULT_CHARSET;
1121 if (!GetCPInfoExW(ml_data->mime_cp_info[index].cp, 0, &cpinfo))
1123 /* fall back to family codepage in the case of alias */
1124 if (!GetCPInfoExW(ml_data->family_codepage, 0, &cpinfo))
1125 cpinfo.CodePageName[0] = 0;
1128 mime_cp_info->dwFlags = ml_data->mime_cp_info[index].flags;
1129 mime_cp_info->uiCodePage = ml_data->mime_cp_info[index].cp;
1130 mime_cp_info->uiFamilyCodePage = ml_data->family_codepage;
1131 strcpyW(mime_cp_info->wszDescription, cpinfo.CodePageName);
1132 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].web_charset, -1,
1133 mime_cp_info->wszWebCharset, sizeof(mime_cp_info->wszWebCharset)/sizeof(WCHAR));
1134 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].header_charset, -1,
1135 mime_cp_info->wszHeaderCharset, sizeof(mime_cp_info->wszHeaderCharset)/sizeof(WCHAR));
1136 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].body_charset, -1,
1137 mime_cp_info->wszBodyCharset, sizeof(mime_cp_info->wszBodyCharset)/sizeof(WCHAR));
1140 GetObjectW(GetStockObject(SYSTEM_FIXED_FONT), sizeof(lf), &lf);
1141 strcpyW(mime_cp_info->wszFixedWidthFont, lf.lfFaceName);
1143 GetObjectW(GetStockObject(DEFAULT_GUI_FONT), sizeof(lf), &lf);
1144 strcpyW(mime_cp_info->wszProportionalFont, lf.lfFaceName);
1147 static HRESULT WINAPI fnIMultiLanguage2_GetCodePageInfo(
1148 IMultiLanguage2* iface,
1151 PMIMECPINFO pCodePageInfo)
1155 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1156 TRACE("%p, %u, %04x, %p\n", This, uiCodePage, LangId, pCodePageInfo);
1158 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1160 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1162 if (mlang_data[i].mime_cp_info[n].cp == uiCodePage)
1164 fill_cp_info(&mlang_data[i], n, pCodePageInfo);
1173 static HRESULT WINAPI fnIMultiLanguage2_GetFamilyCodePage(
1174 IMultiLanguage2* iface,
1176 UINT* puiFamilyCodePage)
1180 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1181 TRACE("%p %d %p\n", This, uiCodePage, puiFamilyCodePage);
1183 if (!puiFamilyCodePage) return S_FALSE;
1185 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1187 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1189 if (mlang_data[i].mime_cp_info[n].cp == uiCodePage)
1191 *puiFamilyCodePage = mlang_data[i].family_codepage;
1200 static HRESULT WINAPI fnIMultiLanguage2_EnumCodePages(
1201 IMultiLanguage2* iface,
1204 IEnumCodePage** ppEnumCodePage)
1206 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1207 TRACE("%p %08lx %04x %p\n", This, grfFlags, LangId, ppEnumCodePage);
1209 return EnumCodePage_create( This, grfFlags, LangId, ppEnumCodePage );
1212 static HRESULT WINAPI fnIMultiLanguage2_GetCharsetInfo(
1213 IMultiLanguage2* iface,
1215 PMIMECSETINFO pCharsetInfo)
1217 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1218 FIXME("%p %s %p\n", This, debugstr_w(Charset), pCharsetInfo);
1222 static HRESULT WINAPI fnIMultiLanguage2_IsConvertible(
1223 IMultiLanguage2* iface,
1224 DWORD dwSrcEncoding,
1225 DWORD dwDstEncoding)
1227 UINT src_family, dst_family;
1229 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1230 TRACE("%p %ld %ld\n", This, dwSrcEncoding, dwDstEncoding);
1232 if (fnIMultiLanguage2_GetFamilyCodePage(iface, dwSrcEncoding, &src_family) != S_OK ||
1233 fnIMultiLanguage2_GetFamilyCodePage(iface, dwDstEncoding, &dst_family) != S_OK)
1236 if (src_family == dst_family) return S_OK;
1238 /* we can convert any codepage to/from unicode */
1239 if (src_family == CP_UNICODE || dst_family == CP_UNICODE) return S_OK;
1244 static HRESULT WINAPI fnIMultiLanguage2_ConvertString(
1245 IMultiLanguage2* iface,
1247 DWORD dwSrcEncoding,
1248 DWORD dwDstEncoding,
1258 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringToUnicode(
1259 IMultiLanguage2* iface,
1269 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1270 TRACE("%p %p %ld %s %p %p %p\n", This, pdwMode, dwEncoding,
1271 debugstr_a(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
1277 pcSrcSize = &src_len;
1288 if (*pcSrcSize == -1)
1289 *pcSrcSize = lstrlenW((LPCWSTR)pSrcStr);
1290 *pcDstSize = min(*pcSrcSize, *pcDstSize);
1291 *pcSrcSize *= sizeof(WCHAR);
1292 memmove(pDstStr, pSrcStr, *pcDstSize * sizeof(WCHAR));
1296 if (*pcSrcSize == -1)
1297 *pcSrcSize = lstrlenA(pSrcStr);
1299 *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, pDstStr, *pcDstSize);
1309 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringFromUnicode(
1310 IMultiLanguage2* iface,
1320 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1321 TRACE("%p %p %ld %s %p %p %p\n", This, pdwMode, dwEncoding,
1322 debugstr_w(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
1328 pcSrcSize = &src_len;
1339 if (*pcSrcSize == -1)
1340 *pcSrcSize = lstrlenW(pSrcStr);
1341 *pcDstSize = min(*pcSrcSize * sizeof(WCHAR), *pcDstSize);
1342 memmove(pDstStr, pSrcStr, *pcDstSize);
1346 if (*pcSrcSize == -1)
1347 *pcSrcSize = lstrlenW(pSrcStr);
1349 *pcDstSize = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize, pDstStr, *pcDstSize, NULL, NULL);
1360 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringReset(
1361 IMultiLanguage2* iface)
1367 static HRESULT WINAPI fnIMultiLanguage2_GetRfc1766FromLcid(
1368 IMultiLanguage2* iface,
1376 static HRESULT WINAPI fnIMultiLanguage2_GetLcidFromRfc1766(
1377 IMultiLanguage2* iface,
1385 static HRESULT WINAPI fnIMultiLanguage2_EnumRfc1766(
1386 IMultiLanguage2* iface,
1388 IEnumRfc1766** ppEnumRfc1766)
1394 static HRESULT WINAPI fnIMultiLanguage2_GetRfc1766Info(
1395 IMultiLanguage2* iface,
1398 PRFC1766INFO pRfc1766Info)
1404 static HRESULT WINAPI fnIMultiLanguage2_CreateConvertCharset(
1405 IMultiLanguage2* iface,
1409 IMLangConvertCharset** ppMLangConvertCharset)
1415 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringInIStream(
1416 IMultiLanguage2* iface,
1420 DWORD dwSrcEncoding,
1421 DWORD dwDstEncoding,
1429 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringToUnicodeEx(
1430 IMultiLanguage2* iface,
1444 static HRESULT WINAPI fnIMultiLanguage2_DetectCodepageInIStream(
1445 IMultiLanguage2* iface,
1447 DWORD dwPrefWinCodePage,
1449 DetectEncodingInfo* lpEncoding,
1456 static HRESULT WINAPI fnIMultiLanguage2_DetectInputCodepage(
1457 IMultiLanguage2* iface,
1459 DWORD dwPrefWinCodePage,
1462 DetectEncodingInfo* lpEncoding,
1469 static HRESULT WINAPI fnIMultiLanguage2_ValidateCodePage(
1470 IMultiLanguage2* iface,
1478 static HRESULT WINAPI fnIMultiLanguage2_GetCodePageDescription(
1479 IMultiLanguage2* iface,
1482 LPWSTR lpWideCharStr,
1489 static HRESULT WINAPI fnIMultiLanguage2_IsCodePageInstallable(
1490 IMultiLanguage2* iface,
1497 static HRESULT WINAPI fnIMultiLanguage2_SetMimeDBSource(
1498 IMultiLanguage2* iface,
1505 static HRESULT WINAPI fnIMultiLanguage2_GetNumberOfScripts(
1506 IMultiLanguage2* iface,
1513 static HRESULT WINAPI fnIMultiLanguage2_EnumScripts(
1514 IMultiLanguage2* iface,
1517 IEnumScript** ppEnumScript)
1523 static HRESULT WINAPI fnIMultiLanguage2_ValidateCodePageEx(
1524 IMultiLanguage2* iface,
1527 DWORD dwfIODControl)
1533 static ICOM_VTABLE(IMultiLanguage2) IMultiLanguage2_vtbl =
1535 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1536 fnIMultiLanguage2_QueryInterface,
1537 fnIMultiLanguage2_AddRef,
1538 fnIMultiLanguage2_Release,
1539 fnIMultiLanguage2_GetNumberOfCodePageInfo,
1540 fnIMultiLanguage2_GetCodePageInfo,
1541 fnIMultiLanguage2_GetFamilyCodePage,
1542 fnIMultiLanguage2_EnumCodePages,
1543 fnIMultiLanguage2_GetCharsetInfo,
1544 fnIMultiLanguage2_IsConvertible,
1545 fnIMultiLanguage2_ConvertString,
1546 fnIMultiLanguage2_ConvertStringToUnicode,
1547 fnIMultiLanguage2_ConvertStringFromUnicode,
1548 fnIMultiLanguage2_ConvertStringReset,
1549 fnIMultiLanguage2_GetRfc1766FromLcid,
1550 fnIMultiLanguage2_GetLcidFromRfc1766,
1551 fnIMultiLanguage2_EnumRfc1766,
1552 fnIMultiLanguage2_GetRfc1766Info,
1553 fnIMultiLanguage2_CreateConvertCharset,
1554 fnIMultiLanguage2_ConvertStringInIStream,
1555 fnIMultiLanguage2_ConvertStringToUnicodeEx,
1556 fnIMultiLanguage2_DetectCodepageInIStream,
1557 fnIMultiLanguage2_DetectInputCodepage,
1558 fnIMultiLanguage2_ValidateCodePage,
1559 fnIMultiLanguage2_GetCodePageDescription,
1560 fnIMultiLanguage2_IsCodePageInstallable,
1561 fnIMultiLanguage2_SetMimeDBSource,
1562 fnIMultiLanguage2_GetNumberOfScripts,
1563 fnIMultiLanguage2_EnumScripts,
1564 fnIMultiLanguage2_ValidateCodePageEx,
1567 static HRESULT MultiLanguage_create(IUnknown *pUnkOuter, LPVOID *ppObj)
1572 TRACE("Creating MultiLanguage object\n");
1574 mlang = HeapAlloc( GetProcessHeap(), 0, sizeof (MLang_impl) );
1575 mlang->vtbl_IMLangFontLink = &IMLangFontLink_vtbl;
1576 mlang->vtbl_IMultiLanguage = &IMultiLanguage_vtbl;
1577 mlang->vtbl_IMultiLanguage2 = &IMultiLanguage2_vtbl;
1580 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1581 mlang->total += mlang_data[i].number_of_cp;
1584 *ppObj = (LPVOID) mlang;
1585 TRACE("returning %p\n", mlang);
1589 /******************************************************************************/
1591 HRESULT WINAPI MLANG_DllCanUnloadNow(void)
1597 HRESULT WINAPI MLANG_DllRegisterServer(void)
1603 HRESULT WINAPI MLANG_DllUnregisterServer(void)