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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
37 #include "wine/unicode.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(mlang
);
44 #define CP_UNICODE 1200
46 #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
48 static HRESULT
MultiLanguage_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
49 static HRESULT
EnumRfc1766_create(LANGID LangId
, IEnumRfc1766
**ppEnum
);
51 static DWORD MLANG_tls_index
; /* to store various per thead data */
54 * Under what circumstances HKEY_CLASSES_ROOT\MIME\Database\Codepage and
55 * HKEY_CLASSES_ROOT\MIME\Database\Charset are used?
60 const char *description
;
63 const char *web_charset
;
64 const char *header_charset
;
65 const char *body_charset
;
68 /* These data are based on the codepage info in libs/unicode/cpmap.pl */
69 /* FIXME: Add 28604 (Celtic), 28606 (Balkan) */
71 static const MIME_CP_INFO arabic_cp
[] =
74 864, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
75 MIMECONTF_MIME_LATEST
,
76 "ibm864", "ibm864", "ibm864" },
78 1006, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
79 MIMECONTF_MIME_LATEST
,
80 "ibm1006", "ibm1006", "ibm1006" },
82 1256, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
83 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
84 MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
85 "windows-1256", "windows-1256", "windows-1256" },
87 28596, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
88 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
89 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
90 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
91 "iso-8859-6", "iso-8859-6", "iso-8859-6" }
93 static const MIME_CP_INFO baltic_cp
[] =
96 775, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
97 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
98 "ibm775", "ibm775", "ibm775" },
100 1257, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
101 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
102 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
103 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
104 "windows-1257", "windows-1257", "windows-1257" },
106 28594, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
107 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
108 MIMECONTF_EXPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
109 MIMECONTF_MIME_LATEST
,
110 "iso-8859-4", "iso-8859-4", "iso-8859-4" },
112 28603, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
113 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
114 "iso-8859-13", "iso-8859-13", "iso-8859-13" }
116 static const MIME_CP_INFO chinese_simplified_cp
[] =
118 { "Chinese Simplified (GB2312)",
119 936, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
120 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
121 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
122 MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
123 "gb2312", "gb2312", "gb2312" }
125 static const MIME_CP_INFO chinese_traditional_cp
[] =
127 { "Chinese Traditional (Big5)",
128 950, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
129 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
130 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
131 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
132 "big5", "big5", "big5" }
134 static const MIME_CP_INFO central_european_cp
[] =
136 { "Central European (DOS)",
137 852, MIMECONTF_BROWSER
| MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_BROWSER
|
138 MIMECONTF_EXPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
139 MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
140 "ibm852", "ibm852", "ibm852" },
141 { "Central European (Windows)",
142 1250, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
143 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
144 MIMECONTF_EXPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
145 MIMECONTF_MIME_LATEST
,
146 "windows-1250", "windows-1250", "windows-1250" },
147 { "Central European (Mac)",
148 10029, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
149 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
150 "x-mac-ce", "x-mac-ce", "x-mac-ce" },
151 { "Central European (ISO)",
152 28592, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
153 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
154 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
155 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
156 "iso-8859-2", "iso-8859-2", "iso-8859-2" }
158 static const MIME_CP_INFO cyrillic_cp
[] =
161 855, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
162 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
163 "ibm855", "ibm855", "ibm855" },
165 866, MIMECONTF_BROWSER
| MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_BROWSER
|
166 MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
|
167 MIMECONTF_MIME_LATEST
,
168 "cp866", "cp866", "cp866" },
169 #if 0 /* Windows has 20866 as an official code page for KOI8-R */
170 { "Cyrillic (KOI8-R)",
171 878, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
172 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
173 "koi8-r", "koi8-r", "koi8-r" },
175 { "Cyrillic (Windows)",
176 1251, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
177 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
178 MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
179 "windows-1251", "windows-1251", "windows-1251" },
181 10007, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
182 MIMECONTF_MIME_LATEST
,
183 "x-mac-cyrillic", "x-mac-cyrillic", "x-mac-cyrillic" },
184 { "Cyrillic (KOI8-R)",
185 20866, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
186 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
187 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
188 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
189 "koi8-r", "koi8-r", "koi8-r" },
190 { "Cyrillic (KOI8-U)",
191 21866, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
192 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
193 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
194 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
195 "koi8-u", "koi8-u", "koi8-u" },
197 28595, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
198 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
199 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
200 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
201 "iso-8859-5", "iso-8859-5", "iso-8859-5" }
203 static const MIME_CP_INFO greek_cp
[] =
206 737, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
207 MIMECONTF_MIME_LATEST
,
208 "ibm737", "ibm737", "ibm737" },
209 { "Greek, Modern (DOS)",
210 869, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
211 MIMECONTF_MIME_LATEST
,
212 "ibm869", "ibm869", "ibm869" },
213 { "IBM EBCDIC (Greek Modern)",
214 875, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
215 MIMECONTF_MIME_LATEST
,
216 "cp875", "cp875", "cp875" },
218 1253, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
219 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
220 MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
221 "windows-1253", "windows-1253", "windows-1253" },
223 10006, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
224 MIMECONTF_MIME_LATEST
,
225 "x-mac-greek", "x-mac-greek", "x-mac-greek" },
227 28597, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
228 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
229 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
230 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
231 "iso-8859-7", "iso-8859-7", "iso-8859-7" }
233 static const MIME_CP_INFO hebrew_cp
[] =
236 424, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
237 MIMECONTF_MIME_LATEST
,
238 "ibm424", "ibm424", "ibm424" },
240 856, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
241 MIMECONTF_MIME_LATEST
,
242 "cp856", "cp856", "cp856" },
244 862, MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
| MIMECONTF_IMPORT
|
245 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
246 MIMECONTF_MIME_LATEST
,
247 "dos-862", "dos-862", "dos-862" },
248 { "Hebrew (Windows)",
249 1255, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
250 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
251 MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
252 "windows-1255", "windows-1255", "windows-1255" },
253 { "Hebrew (ISO-Visual)",
254 28598, MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
| MIMECONTF_IMPORT
|
255 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
256 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
257 "iso-8859-8", "iso-8859-8", "iso-8859-8" }
259 static const MIME_CP_INFO japanese_cp
[] =
261 { "Japanese (Auto-Select)",
262 50932, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
263 MIMECONTF_IMPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
264 MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
265 "_autodetect", "_autodetect", "_autodetect" },
267 51932, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
268 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
269 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
270 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
271 "euc-jp", "euc-jp", "euc-jp" },
273 50220, MIMECONTF_IMPORT
| MIMECONTF_MAILNEWS
| MIMECONTF_EXPORT
|
274 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_VALID_NLS
|
275 MIMECONTF_PRIVCONVERTER
| MIMECONTF_MIME_LATEST
|
277 "iso-2022-jp","iso-2022-jp","iso-2022-jp"},
278 { "Japanese (JIS 0208-1990 and 0212-1990)",
279 20932, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
280 MIMECONTF_VALID
| MIMECONTF_PRIVCONVERTER
| MIMECONTF_MIME_LATEST
,
281 "EUC-JP","EUC-JP","EUC-JP"},
282 { "Japanese (JIS-Allow 1 byte Kana)",
283 50221, MIMECONTF_MAILNEWS
| MIMECONTF_EXPORT
| MIMECONTF_SAVABLE_BROWSER
|
284 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_VALID_NLS
|
285 MIMECONTF_VALID
| MIMECONTF_PRIVCONVERTER
| MIMECONTF_MIME_LATEST
,
286 "csISO2022JP","iso-2022-jp","iso-2022-jp"},
287 { "Japanese (JIS-Allow 1 byte Kana - SO/SI)",
288 50222, MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
| MIMECONTF_VALID
|
289 MIMECONTF_PRIVCONVERTER
| MIMECONTF_MIME_LATEST
,
290 "iso-2022-jp","iso-2022-jp","iso-2022-jp"},
292 10001, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
293 MIMECONTF_VALID
| MIMECONTF_PRIVCONVERTER
| MIMECONTF_MIME_LATEST
,
294 "x-mac-japanese","x-mac-japanese","x-mac-japanese"},
295 { "Japanese (Shift-JIS)",
296 932, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
297 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
298 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
299 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
300 "shift_jis", "iso-2022-jp", "iso-2022-jp" }
302 static const MIME_CP_INFO korean_cp
[] =
305 949, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
306 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
307 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
308 MIMECONTF_MIME_LATEST
,
309 "ks_c_5601-1987", "ks_c_5601-1987", "ks_c_5601-1987" }
311 static const MIME_CP_INFO thai_cp
[] =
314 874, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_MIME_LATEST
,
315 "ibm-thai", "ibm-thai", "ibm-thai" }
317 static const MIME_CP_INFO turkish_cp
[] =
320 857, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
321 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
322 "ibm857", "ibm857", "ibm857" },
323 { "IBM EBCDIC (Turkish Latin-5)",
324 1026, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
325 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
326 "ibm1026", "ibm1026", "ibm1026" },
327 { "Turkish (Windows)",
328 1254, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
329 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
330 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
331 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
332 "windows-1254", "windows-1254", "windows-1254" },
334 10081, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
335 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
336 "x-mac-turkish", "x-mac-turkish", "x-mac-turkish" },
338 28593, MIMECONTF_MAILNEWS
| MIMECONTF_IMPORT
|
339 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
340 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
341 "iso-8859-3", "iso-8859-3", "iso-8859-3" },
343 28599, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
344 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
345 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
346 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
347 "iso-8859-9", "iso-8859-9", "iso-8859-9" }
349 static const MIME_CP_INFO vietnamese_cp
[] =
351 { "Vietnamese (Windows)",
352 1258, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
353 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
354 MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
|
355 MIMECONTF_MIME_LATEST
,
356 "windows-1258", "windows-1258", "windows-1258" }
358 static const MIME_CP_INFO western_cp
[] =
360 { "IBM EBCDIC (US-Canada)",
361 37, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
362 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
363 "ibm037", "ibm037", "ibm037" },
364 { "OEM United States",
365 437, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
366 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
367 "ibm437", "ibm437", "ibm437" },
368 { "IBM EBCDIC (International)",
369 500, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
370 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
371 "ibm500", "ibm500", "ibm500" },
372 { "Western European (DOS)",
373 850, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
374 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
375 "ibm850", "ibm850", "ibm850" },
376 { "Portuguese (DOS)",
377 860, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
378 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
379 "ibm860", "ibm860", "ibm860" },
381 861, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
382 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
383 "ibm861", "ibm861", "ibm861" },
384 { "French Canadian (DOS)",
385 863, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
386 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
387 "ibm863", "ibm863", "ibm863" },
389 865, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
390 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
391 "ibm865", "ibm865", "ibm865" },
392 { "Western European (Windows)",
393 1252, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
394 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
395 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
396 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
397 "windows-1252", "windows-1252", "iso-8859-1" },
398 { "Western European (Mac)",
399 10000, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
400 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
401 "macintosh", "macintosh", "macintosh" },
403 10079, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
404 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
405 "x-mac-icelandic", "x-mac-icelandic", "x-mac-icelandic" },
407 20127, MIMECONTF_MAILNEWS
| MIMECONTF_IMPORT
| MIMECONTF_EXPORT
|
408 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_VALID
|
409 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
410 "us-ascii", "us-ascii", "us-ascii" },
411 { "Western European (ISO)",
412 28591, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
413 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
414 MIMECONTF_EXPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
415 MIMECONTF_MIME_LATEST
,
416 "iso-8859-1", "iso-8859-1", "iso-8859-1" },
418 28605, MIMECONTF_MAILNEWS
| MIMECONTF_IMPORT
|
419 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
420 MIMECONTF_EXPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
421 MIMECONTF_MIME_LATEST
,
422 "iso-8859-15", "iso-8859-15", "iso-8859-15" }
424 static const MIME_CP_INFO unicode_cp
[] =
427 CP_UNICODE
, MIMECONTF_MINIMAL
| MIMECONTF_IMPORT
|
428 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
429 MIMECONTF_VALID
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
|
430 MIMECONTF_MIME_LATEST
,
431 "unicode", "unicode", "unicode" },
433 CP_UTF7
, MIMECONTF_MAILNEWS
| MIMECONTF_IMPORT
|
434 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
435 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
436 "utf-7", "utf-7", "utf-7" },
438 CP_UTF8
, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
439 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
440 MIMECONTF_EXPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
441 MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
442 "utf-8", "utf-8", "utf-8" }
445 static const struct mlang_data
447 const char *description
;
448 UINT family_codepage
;
450 const MIME_CP_INFO
*mime_cp_info
;
451 const char *fixed_font
;
452 const char *proportional_font
;
455 { "Arabic",1256,sizeof(arabic_cp
)/sizeof(arabic_cp
[0]),arabic_cp
,
456 "Courier","Arial" }, /* FIXME */
457 { "Baltic",1257,sizeof(baltic_cp
)/sizeof(baltic_cp
[0]),baltic_cp
,
458 "Courier","Arial" }, /* FIXME */
459 { "Chinese Simplified",936,sizeof(chinese_simplified_cp
)/sizeof(chinese_simplified_cp
[0]),chinese_simplified_cp
,
460 "Courier","Arial" }, /* FIXME */
461 { "Chinese Traditional",950,sizeof(chinese_traditional_cp
)/sizeof(chinese_traditional_cp
[0]),chinese_traditional_cp
,
462 "Courier","Arial" }, /* FIXME */
463 { "Central European",1250,sizeof(central_european_cp
)/sizeof(central_european_cp
[0]),central_european_cp
,
464 "Courier","Arial" }, /* FIXME */
465 { "Cyrillic",1251,sizeof(cyrillic_cp
)/sizeof(cyrillic_cp
[0]),cyrillic_cp
,
466 "Courier","Arial" }, /* FIXME */
467 { "Greek",1253,sizeof(greek_cp
)/sizeof(greek_cp
[0]),greek_cp
,
468 "Courier","Arial" }, /* FIXME */
469 { "Hebrew",1255,sizeof(hebrew_cp
)/sizeof(hebrew_cp
[0]),hebrew_cp
,
470 "Courier","Arial" }, /* FIXME */
471 { "Japanese",932,sizeof(japanese_cp
)/sizeof(japanese_cp
[0]),japanese_cp
,
472 "MS Gothic","MS PGothic" },
473 { "Korean",949,sizeof(korean_cp
)/sizeof(korean_cp
[0]),korean_cp
,
474 "Courier","Arial" }, /* FIXME */
475 { "Thai",874,sizeof(thai_cp
)/sizeof(thai_cp
[0]),thai_cp
,
476 "Courier","Arial" }, /* FIXME */
477 { "Turkish",1254,sizeof(turkish_cp
)/sizeof(turkish_cp
[0]),turkish_cp
,
478 "Courier","Arial" }, /* FIXME */
479 { "Vietnamese",1258,sizeof(vietnamese_cp
)/sizeof(vietnamese_cp
[0]),vietnamese_cp
,
480 "Courier","Arial" }, /* FIXME */
481 { "Western European",1252,sizeof(western_cp
)/sizeof(western_cp
[0]),western_cp
,
482 "Courier","Arial" }, /* FIXME */
483 { "Unicode",CP_UNICODE
,sizeof(unicode_cp
)/sizeof(unicode_cp
[0]),unicode_cp
,
484 "Courier","Arial" } /* FIXME */
487 static void fill_cp_info(const struct mlang_data
*ml_data
, UINT index
, MIMECPINFO
*mime_cp_info
);
489 static LONG dll_count
;
492 * Japanese Detection and Converstion Functions
495 #define HANKATA(A) ((A >= 161) && (A <= 223))
496 #define ISEUC(A) ((A >= 161) && (A <= 254))
497 #define NOTEUC(A,B) (((A >= 129) && (A <= 159)) && ((B >= 64) && (B <= 160)))
498 #define SJIS1(A) (((A >= 129) && (A <= 159)) || ((A >= 224) && (A <= 239)))
499 #define SJIS2(A) ((A >= 64) && (A <= 252))
500 #define ISMARU(A) ((A >= 202) && (A <= 206))
501 #define ISNIGORI(A) (((A >= 182) && (A <= 196)) || ((A >= 202) && (A <= 206)))
503 static UINT
DetectJapaneseCode(LPCSTR input
, DWORD count
)
509 while ((code
== 0 || code
== 51932) && i
< count
)
512 if (c1
== 0x1b /* ESC */)
524 if (c1
=='B' || c1
== '@')
538 else if (ISEUC(c1
) && ISEUC(c2
))
540 else if (((c1
== 142)) && HANKATA(c2
))
548 static inline void jis2sjis(unsigned char *p1
, unsigned char *p2
)
550 unsigned char c1
= *p1
;
551 unsigned char c2
= *p2
;
552 int row
= c1
< 95 ? 112 : 176;
553 int cell
= c1
% 2 ? 31 + (c2
> 95) : 126;
555 *p1
= ((c1
+ 1) >> 1) + row
;
559 static inline void sjis2jis(unsigned char *p1
, unsigned char *p2
)
561 unsigned char c1
= *p1
;
562 unsigned char c2
= *p2
;
563 int shift
= c2
< 159;
564 int row
= c1
< 160 ? 112 : 176;
565 int cell
= shift
? (31 + (c2
> 127)): 126;
567 *p1
= ((c1
- row
) << 1) - shift
;
571 static int han2zen(unsigned char *p1
, unsigned char *p2
)
575 static const unsigned char char1
[] = {129,129,129,129,129,131,131,131,131,
576 131,131,131,131,131,131,129,131,131,131,131,131,131,131,131,131,131,
577 131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,
578 131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,
580 static const unsigned char char2
[] = {66,117,118,65,69,146,64,66,68,70,
581 72,131,133,135,98,91,65,67,69,71,73,74,76,78,80,82,84,86,88,90,92,94,
582 96,99,101,103,105,106,107,108,109,110,113,116,119,122,125,126,128,
583 129,130,132,134,136,137,138,139,140,141,143,147,74,75};
585 if (( *p2
== 222) && ((ISNIGORI(*p1
) || (*p1
== 179))))
587 else if ((*p2
== 223) && (ISMARU(*p1
)))
590 if (*p1
>= 161 && *p1
<= 223)
592 unsigned char index
= *p1
- 161;
601 if (((*p2
>= 74) && (*p2
<= 103)) || ((*p2
>= 110) && (*p2
<= 122)))
603 else if ((*p1
== 131) && (*p2
== 69))
606 else if ((maru
) && ((*p2
>= 110) && (*p2
<= 122)))
616 static UINT
ConvertJIS2SJIS(LPCSTR input
, DWORD count
, LPSTR output
)
626 if (p
== 0x1b /* ESC */)
632 if (p2
== '$' || p2
=='(')
634 if (p2
== 'K' || p2
=='$')
661 static inline int exit_shift(LPSTR out
, int c
)
672 static inline int enter_shift(LPSTR out
, int c
)
684 static UINT
ConvertSJIS2JIS(LPCSTR input
, DWORD count
, LPSTR output
)
694 if (p
== 10 || p
== 13) /* NL and CR */
699 j
+= exit_shift(output
,j
);
713 p2
= input
[i
] & 0xff;
720 j
+=enter_shift(output
,j
);
738 p2
= input
[i
+1] & 0xff;
744 j
+=enter_shift(output
,j
);
759 j
+= exit_shift(output
,j
);
771 j
+= exit_shift(output
,j
);
775 static UINT
ConvertJISJapaneseToUnicode(LPCSTR input
, DWORD count
,
776 LPWSTR output
, DWORD out_count
)
780 sjis_string
= HeapAlloc(GetProcessHeap(),0,count
);
781 rc
= ConvertJIS2SJIS(input
,count
,sjis_string
);
784 TRACE("%s\n",debugstr_an(sjis_string
,rc
));
786 rc
= MultiByteToWideChar(932,0,sjis_string
,rc
,output
,out_count
);
788 rc
= MultiByteToWideChar(932,0,sjis_string
,rc
,0,0);
790 HeapFree(GetProcessHeap(),0,sjis_string
);
795 static UINT
ConvertUnknownJapaneseToUnicode(LPCSTR input
, DWORD count
,
796 LPWSTR output
, DWORD out_count
)
800 int code
= DetectJapaneseCode(input
,count
);
801 TRACE("Japanese code %i\n",code
);
806 rc
= MultiByteToWideChar(932,0,input
,count
,output
,out_count
);
808 rc
= MultiByteToWideChar(932,0,input
,count
,0,0);
810 else if (code
== 51932)
813 rc
= MultiByteToWideChar(20932,0,input
,count
,output
,out_count
);
815 rc
= MultiByteToWideChar(20932,0,input
,count
,0,0);
817 else if (code
== 50220)
819 sjis_string
= HeapAlloc(GetProcessHeap(),0,count
);
820 rc
= ConvertJIS2SJIS(input
,count
,sjis_string
);
823 TRACE("%s\n",debugstr_an(sjis_string
,rc
));
825 rc
= MultiByteToWideChar(932,0,sjis_string
,rc
,output
,out_count
);
827 rc
= MultiByteToWideChar(932,0,sjis_string
,rc
,0,0);
829 HeapFree(GetProcessHeap(),0,sjis_string
);
834 static UINT
ConvertJapaneseUnicodeToJIS(LPCWSTR input
, DWORD count
,
835 LPSTR output
, DWORD out_count
)
841 len
= WideCharToMultiByte(932,0,input
,count
,0,0,NULL
,NULL
);
842 sjis_string
= HeapAlloc(GetProcessHeap(),0,len
);
843 WideCharToMultiByte(932,0,input
,count
,sjis_string
,len
,NULL
,NULL
);
844 TRACE("%s\n",debugstr_an(sjis_string
,len
));
846 rc
= ConvertSJIS2JIS(sjis_string
, len
, NULL
);
849 ConvertSJIS2JIS(sjis_string
, len
, output
);
851 HeapFree(GetProcessHeap(),0,sjis_string
);
857 * Dll lifetime tracking declaration
859 static void LockModule(void)
861 InterlockedIncrement(&dll_count
);
864 static void UnlockModule(void)
866 InterlockedDecrement(&dll_count
);
869 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
872 case DLL_PROCESS_ATTACH
:
873 MLANG_tls_index
= TlsAlloc();
874 DisableThreadLibraryCalls(hInstDLL
);
876 case DLL_PROCESS_DETACH
:
877 TlsFree(MLANG_tls_index
);
883 HRESULT WINAPI
ConvertINetMultiByteToUnicode(
893 TRACE("%p %d %s %p %p %p\n", pdwMode
, dwEncoding
,
894 debugstr_a(pSrcStr
), pcSrcSize
, pDstStr
, pcDstSize
);
900 pcSrcSize
= &src_len
;
908 /* forwarding euc-jp to EUC-JP */
909 if (dwEncoding
== 51932)
915 if (*pcSrcSize
== -1)
916 *pcSrcSize
= lstrlenW((LPCWSTR
)pSrcStr
);
917 *pcDstSize
= min(*pcSrcSize
, *pcDstSize
);
918 *pcSrcSize
*= sizeof(WCHAR
);
920 memmove(pDstStr
, pSrcStr
, *pcDstSize
* sizeof(WCHAR
));
926 *pcDstSize
= ConvertJISJapaneseToUnicode(pSrcStr
,*pcSrcSize
,pDstStr
,*pcDstSize
);
929 *pcDstSize
= ConvertUnknownJapaneseToUnicode(pSrcStr
,*pcSrcSize
,pDstStr
,*pcDstSize
);
933 if (*pcSrcSize
== -1)
934 *pcSrcSize
= lstrlenA(pSrcStr
);
937 *pcDstSize
= MultiByteToWideChar(dwEncoding
, 0, pSrcStr
, *pcSrcSize
, pDstStr
, *pcDstSize
);
939 *pcDstSize
= MultiByteToWideChar(dwEncoding
, 0, pSrcStr
, *pcSrcSize
, NULL
, 0);
949 HRESULT WINAPI
ConvertINetUnicodeToMultiByte(
960 TRACE("%p %d %s %p %p %p\n", pdwMode
, dwEncoding
,
961 debugstr_w(pSrcStr
), pcSrcSize
, pDstStr
, pcDstSize
);
967 pcSrcSize
= &src_len
;
969 destsz
= (pDstStr
) ? *pcDstSize
: 0;
972 if (!pSrcStr
|| !*pcSrcSize
)
975 if (*pcSrcSize
== -1)
976 *pcSrcSize
= lstrlenW(pSrcStr
);
978 /* forwarding euc-jp to EUC-JP */
979 if (dwEncoding
== 51932)
982 if (dwEncoding
== CP_UNICODE
)
984 if (*pcSrcSize
== -1)
985 *pcSrcSize
= lstrlenW(pSrcStr
);
987 size
= min(*pcSrcSize
, destsz
) * sizeof(WCHAR
);
989 memmove(pDstStr
, pSrcStr
, size
);
994 else if (dwEncoding
== 50220 || dwEncoding
== 50221 || dwEncoding
== 50222)
996 size
= ConvertJapaneseUnicodeToJIS(pSrcStr
, *pcSrcSize
, NULL
, 0);
1002 size
= ConvertJapaneseUnicodeToJIS(pSrcStr
, *pcSrcSize
, pDstStr
,
1011 size
= WideCharToMultiByte(dwEncoding
, 0, pSrcStr
, *pcSrcSize
,
1012 NULL
, 0, NULL
, NULL
);
1018 size
= WideCharToMultiByte(dwEncoding
, 0, pSrcStr
, *pcSrcSize
,
1019 pDstStr
, destsz
, NULL
, NULL
);
1034 HRESULT WINAPI
ConvertINetString(
1036 DWORD dwSrcEncoding
,
1037 DWORD dwDstEncoding
,
1044 TRACE("%p %d %d %s %p %p %p\n", pdwMode
, dwSrcEncoding
, dwDstEncoding
,
1045 debugstr_a(pSrcStr
), pcSrcSize
, pDstStr
, pcDstSize
);
1047 if (dwSrcEncoding
== CP_UNICODE
)
1050 if (pcSrcSize
&& *pcSrcSize
!= -1)
1052 cSrcSizeW
= *pcSrcSize
/ sizeof(WCHAR
);
1053 pcSrcSize
= &cSrcSizeW
;
1055 return ConvertINetUnicodeToMultiByte(pdwMode
, dwDstEncoding
, (LPCWSTR
)pSrcStr
, pcSrcSize
, pDstStr
, pcDstSize
);
1057 else if (dwDstEncoding
== CP_UNICODE
)
1059 HRESULT hr
= ConvertINetMultiByteToUnicode(pdwMode
, dwSrcEncoding
, pSrcStr
, pcSrcSize
, (LPWSTR
)pDstStr
, pcDstSize
);
1060 *pcDstSize
*= sizeof(WCHAR
);
1069 TRACE("convert %s from %d to %d\n", debugstr_a(pSrcStr
), dwSrcEncoding
, dwDstEncoding
);
1071 hr
= ConvertINetMultiByteToUnicode(pdwMode
, dwSrcEncoding
, pSrcStr
, pcSrcSize
, NULL
, &cDstSizeW
);
1075 pDstStrW
= HeapAlloc(GetProcessHeap(), 0, cDstSizeW
* sizeof(WCHAR
));
1076 hr
= ConvertINetMultiByteToUnicode(pdwMode
, dwSrcEncoding
, pSrcStr
, pcSrcSize
, pDstStrW
, &cDstSizeW
);
1078 hr
= ConvertINetUnicodeToMultiByte(pdwMode
, dwDstEncoding
, pDstStrW
, &cDstSizeW
, pDstStr
, pcDstSize
);
1080 HeapFree(GetProcessHeap(), 0, pDstStrW
);
1085 static HRESULT
GetFamilyCodePage(
1087 UINT
* puiFamilyCodePage
)
1091 TRACE("%u %p\n", uiCodePage
, puiFamilyCodePage
);
1093 if (!puiFamilyCodePage
) return S_FALSE
;
1095 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
1097 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
1099 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
1101 *puiFamilyCodePage
= mlang_data
[i
].family_codepage
;
1110 HRESULT WINAPI
IsConvertINetStringAvailable(
1111 DWORD dwSrcEncoding
,
1112 DWORD dwDstEncoding
)
1114 UINT src_family
, dst_family
;
1116 TRACE("%d %d\n", dwSrcEncoding
, dwDstEncoding
);
1118 if (GetFamilyCodePage(dwSrcEncoding
, &src_family
) != S_OK
||
1119 GetFamilyCodePage(dwDstEncoding
, &dst_family
) != S_OK
)
1122 if (src_family
== dst_family
) return S_OK
;
1124 /* we can convert any codepage to/from unicode */
1125 if (src_family
== CP_UNICODE
|| dst_family
== CP_UNICODE
) return S_OK
;
1130 static inline INT
lcid_to_rfc1766A( LCID lcid
, LPSTR rfc1766
, INT len
)
1132 INT n
= GetLocaleInfoA( lcid
, LOCALE_SISO639LANGNAME
, rfc1766
, len
);
1135 rfc1766
[n
- 1] = '-';
1136 n
+= GetLocaleInfoA( lcid
, LOCALE_SISO3166CTRYNAME
, rfc1766
+ n
, len
- n
);
1137 LCMapStringA( LOCALE_USER_DEFAULT
, LCMAP_LOWERCASE
, rfc1766
, n
, rfc1766
, len
);
1143 static inline INT
lcid_to_rfc1766W( LCID lcid
, LPWSTR rfc1766
, INT len
)
1145 INT n
= GetLocaleInfoW( lcid
, LOCALE_SISO639LANGNAME
, rfc1766
, len
);
1149 rfc1766
[n
- 1] = '-';
1150 n
+= GetLocaleInfoW( lcid
, LOCALE_SISO3166CTRYNAME
, rfc1766
+ n
, len
- n
);
1152 rfc1766
[n
- 1] = '\0';
1153 LCMapStringW( LOCALE_USER_DEFAULT
, LCMAP_LOWERCASE
, rfc1766
, n
, rfc1766
, len
);
1159 HRESULT WINAPI
LcidToRfc1766A(
1164 TRACE("%04x %p %u\n", lcid
, pszRfc1766
, nChar
);
1166 if (lcid_to_rfc1766A( lcid
, pszRfc1766
, nChar
))
1172 HRESULT WINAPI
LcidToRfc1766W(
1177 TRACE("%04x %p %u\n", lcid
, pszRfc1766
, nChar
);
1179 if (lcid_to_rfc1766W( lcid
, pszRfc1766
, nChar
))
1185 static HRESULT
lcid_from_rfc1766(IEnumRfc1766
*iface
, LCID
*lcid
, LPCWSTR rfc1766
)
1190 while (IEnumRfc1766_Next(iface
, 1, &info
, &num
) == S_OK
)
1192 if (!strcmpW(info
.wszRfc1766
, rfc1766
))
1197 if (strlenW(rfc1766
) == 2 && !memcmp(info
.wszRfc1766
, rfc1766
, 2 * sizeof(WCHAR
)))
1199 *lcid
= PRIMARYLANGID(info
.lcid
);
1207 HRESULT WINAPI
Rfc1766ToLcidW(LCID
*pLocale
, LPCWSTR pszRfc1766
)
1209 IEnumRfc1766
*enumrfc1766
;
1212 TRACE("(%p, %s)\n", pLocale
, debugstr_w(pszRfc1766
));
1214 if (!pLocale
|| !pszRfc1766
)
1215 return E_INVALIDARG
;
1219 hr
= EnumRfc1766_create(0, &enumrfc1766
);
1223 hr
= lcid_from_rfc1766(enumrfc1766
, pLocale
, pszRfc1766
);
1224 IEnumRfc1766_Release(enumrfc1766
);
1229 HRESULT WINAPI
Rfc1766ToLcidA(LCID
*lcid
, LPCSTR rfc1766A
)
1231 WCHAR rfc1766W
[MAX_RFC1766_NAME
+ 1];
1233 MultiByteToWideChar(CP_ACP
, 0, rfc1766A
, -1, rfc1766W
, MAX_RFC1766_NAME
);
1234 rfc1766W
[MAX_RFC1766_NAME
] = 0;
1236 return Rfc1766ToLcidW(lcid
, rfc1766W
);
1239 /******************************************************************************
1240 * MLANG ClassFactory
1243 IClassFactory ITF_IClassFactory
;
1246 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
1247 } IClassFactoryImpl
;
1249 struct object_creation_info
1253 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
1256 static const struct object_creation_info object_creation
[] =
1258 { &CLSID_CMultiLanguage
, "CLSID_CMultiLanguage", MultiLanguage_create
},
1261 static HRESULT WINAPI
1262 MLANGCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
)
1264 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
1266 TRACE("%s\n", debugstr_guid(riid
) );
1268 if (IsEqualGUID(riid
, &IID_IUnknown
)
1269 || IsEqualGUID(riid
, &IID_IClassFactory
))
1271 IClassFactory_AddRef(iface
);
1276 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
1277 return E_NOINTERFACE
;
1280 static ULONG WINAPI
MLANGCF_AddRef(LPCLASSFACTORY iface
)
1282 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
1283 return InterlockedIncrement(&This
->ref
);
1286 static ULONG WINAPI
MLANGCF_Release(LPCLASSFACTORY iface
)
1288 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
1290 ULONG ref
= InterlockedDecrement(&This
->ref
);
1294 TRACE("Destroying %p\n", This
);
1295 HeapFree(GetProcessHeap(), 0, This
);
1301 static HRESULT WINAPI
MLANGCF_CreateInstance(LPCLASSFACTORY iface
, LPUNKNOWN pOuter
,
1302 REFIID riid
, LPVOID
*ppobj
)
1304 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
1308 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
1311 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
1312 if (SUCCEEDED(hres
)) {
1313 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
1314 IUnknown_Release(punk
);
1316 TRACE("returning (%p) -> %x\n", *ppobj
, hres
);
1320 static HRESULT WINAPI
MLANGCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
)
1330 static const IClassFactoryVtbl MLANGCF_Vtbl
=
1332 MLANGCF_QueryInterface
,
1335 MLANGCF_CreateInstance
,
1339 /******************************************************************
1340 * DllGetClassObject (MLANG.@)
1342 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
1345 IClassFactoryImpl
*factory
;
1347 TRACE("%s %s %p\n",debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
1349 if ( !IsEqualGUID( &IID_IClassFactory
, iid
)
1350 && ! IsEqualGUID( &IID_IUnknown
, iid
) )
1351 return E_NOINTERFACE
;
1353 for (i
=0; i
< sizeof(object_creation
)/sizeof(object_creation
[0]); i
++)
1355 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
1359 if (i
== sizeof(object_creation
)/sizeof(object_creation
[0]))
1361 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
1362 return CLASS_E_CLASSNOTAVAILABLE
;
1365 TRACE("Creating a class factory for %s\n",object_creation
[i
].szClassName
);
1367 factory
= HeapAlloc(GetProcessHeap(), 0, sizeof(*factory
));
1368 if (factory
== NULL
) return E_OUTOFMEMORY
;
1370 factory
->ITF_IClassFactory
.lpVtbl
= &MLANGCF_Vtbl
;
1373 factory
->pfnCreateInstance
= object_creation
[i
].pfnCreateInstance
;
1375 *ppv
= &(factory
->ITF_IClassFactory
);
1377 TRACE("(%p) <- %p\n", ppv
, &(factory
->ITF_IClassFactory
) );
1383 /******************************************************************************/
1385 typedef struct tagMLang_impl
1387 const IMLangFontLinkVtbl
*vtbl_IMLangFontLink
;
1388 const IMultiLanguageVtbl
*vtbl_IMultiLanguage
;
1389 const IMultiLanguage3Vtbl
*vtbl_IMultiLanguage3
;
1390 const IMLangFontLink2Vtbl
*vtbl_IMLangFontLink2
;
1391 const IMLangLineBreakConsoleVtbl
*vtbl_IMLangLineBreakConsole
;
1393 DWORD total_cp
, total_scripts
;
1396 static ULONG
MLang_AddRef( MLang_impl
* This
)
1398 return InterlockedIncrement(&This
->ref
);
1401 static ULONG
MLang_Release( MLang_impl
* This
)
1403 ULONG ref
= InterlockedDecrement(&This
->ref
);
1405 TRACE("%p ref = %d\n", This
, ref
);
1408 TRACE("Destroying %p\n", This
);
1409 HeapFree(GetProcessHeap(), 0, This
);
1416 static HRESULT
MLang_QueryInterface(
1421 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
1423 if (IsEqualGUID(riid
, &IID_IUnknown
)
1424 || IsEqualGUID(riid
, &IID_IMLangCodePages
)
1425 || IsEqualGUID(riid
, &IID_IMLangFontLink
))
1428 TRACE("Returning IID_IMLangFontLink %p ref = %d\n", This
, This
->ref
);
1429 *ppvObject
= &(This
->vtbl_IMLangFontLink
);
1433 if (IsEqualGUID(riid
, &IID_IMLangFontLink2
))
1436 TRACE("Returning IID_IMLangFontLink2 %p ref = %d\n", This
, This
->ref
);
1437 *ppvObject
= &(This
->vtbl_IMLangFontLink2
);
1441 if (IsEqualGUID(riid
, &IID_IMultiLanguage
) )
1444 TRACE("Returning IID_IMultiLanguage %p ref = %d\n", This
, This
->ref
);
1445 *ppvObject
= &(This
->vtbl_IMultiLanguage
);
1449 if (IsEqualGUID(riid
, &IID_IMultiLanguage2
) )
1452 *ppvObject
= &(This
->vtbl_IMultiLanguage3
);
1453 TRACE("Returning IID_IMultiLanguage2 %p ref = %d\n", This
, This
->ref
);
1457 if (IsEqualGUID(riid
, &IID_IMultiLanguage3
) )
1460 *ppvObject
= &(This
->vtbl_IMultiLanguage3
);
1461 TRACE("Returning IID_IMultiLanguage3 %p ref = %d\n", This
, This
->ref
);
1465 if (IsEqualGUID(riid
, &IID_IMLangLineBreakConsole
))
1468 TRACE("Returning IID_IMLangLineBreakConsole %p ref = %d\n", This
, This
->ref
);
1469 *ppvObject
= &(This
->vtbl_IMLangLineBreakConsole
);
1474 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1475 return E_NOINTERFACE
;
1478 /******************************************************************************/
1480 typedef struct tagEnumCodePage_impl
1482 const IEnumCodePageVtbl
*vtbl_IEnumCodePage
;
1486 } EnumCodePage_impl
;
1488 static HRESULT WINAPI
fnIEnumCodePage_QueryInterface(
1489 IEnumCodePage
* iface
,
1493 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1495 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
1497 if (IsEqualGUID(riid
, &IID_IUnknown
)
1498 || IsEqualGUID(riid
, &IID_IEnumCodePage
))
1500 IEnumCodePage_AddRef(iface
);
1501 TRACE("Returning IID_IEnumCodePage %p ref = %d\n", This
, This
->ref
);
1502 *ppvObject
= &(This
->vtbl_IEnumCodePage
);
1506 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1507 return E_NOINTERFACE
;
1510 static ULONG WINAPI
fnIEnumCodePage_AddRef(
1511 IEnumCodePage
* iface
)
1513 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1514 return InterlockedIncrement(&This
->ref
);
1517 static ULONG WINAPI
fnIEnumCodePage_Release(
1518 IEnumCodePage
* iface
)
1520 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1521 ULONG ref
= InterlockedDecrement(&This
->ref
);
1523 TRACE("%p ref = %d\n", This
, ref
);
1526 TRACE("Destroying %p\n", This
);
1527 HeapFree(GetProcessHeap(), 0, This
->cpinfo
);
1528 HeapFree(GetProcessHeap(), 0, This
);
1534 static HRESULT WINAPI
fnIEnumCodePage_Clone(
1535 IEnumCodePage
* iface
,
1536 IEnumCodePage
** ppEnum
)
1538 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1539 FIXME("%p %p\n", This
, ppEnum
);
1543 static HRESULT WINAPI
fnIEnumCodePage_Next(
1544 IEnumCodePage
* iface
,
1547 ULONG
* pceltFetched
)
1551 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1552 TRACE("%p %u %p %p\n", This
, celt
, rgelt
, pceltFetched
);
1554 if (!pceltFetched
) return S_FALSE
;
1557 if (!rgelt
) return S_FALSE
;
1559 if (This
->pos
+ celt
> This
->total
)
1560 celt
= This
->total
- This
->pos
;
1562 if (!celt
) return S_FALSE
;
1564 memcpy(rgelt
, This
->cpinfo
+ This
->pos
, celt
* sizeof(MIMECPINFO
));
1565 *pceltFetched
= celt
;
1568 for (i
= 0; i
< celt
; i
++)
1570 TRACE("#%u: %08x %u %u %s %s %s %s %s %s %d\n",
1571 i
, rgelt
[i
].dwFlags
, rgelt
[i
].uiCodePage
,
1572 rgelt
[i
].uiFamilyCodePage
,
1573 wine_dbgstr_w(rgelt
[i
].wszDescription
),
1574 wine_dbgstr_w(rgelt
[i
].wszWebCharset
),
1575 wine_dbgstr_w(rgelt
[i
].wszHeaderCharset
),
1576 wine_dbgstr_w(rgelt
[i
].wszBodyCharset
),
1577 wine_dbgstr_w(rgelt
[i
].wszFixedWidthFont
),
1578 wine_dbgstr_w(rgelt
[i
].wszProportionalFont
),
1579 rgelt
[i
].bGDICharset
);
1584 static HRESULT WINAPI
fnIEnumCodePage_Reset(
1585 IEnumCodePage
* iface
)
1587 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1588 TRACE("%p\n", This
);
1594 static HRESULT WINAPI
fnIEnumCodePage_Skip(
1595 IEnumCodePage
* iface
,
1598 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1599 TRACE("%p %u\n", This
, celt
);
1601 if (celt
>= This
->total
) return S_FALSE
;
1607 static const IEnumCodePageVtbl IEnumCodePage_vtbl
=
1609 fnIEnumCodePage_QueryInterface
,
1610 fnIEnumCodePage_AddRef
,
1611 fnIEnumCodePage_Release
,
1612 fnIEnumCodePage_Clone
,
1613 fnIEnumCodePage_Next
,
1614 fnIEnumCodePage_Reset
,
1615 fnIEnumCodePage_Skip
1618 static HRESULT
EnumCodePage_create( MLang_impl
* mlang
, DWORD grfFlags
,
1619 LANGID LangId
, IEnumCodePage
** ppEnumCodePage
)
1621 EnumCodePage_impl
*ecp
;
1625 TRACE("%p, %08x, %04x, %p\n", mlang
, grfFlags
, LangId
, ppEnumCodePage
);
1627 if (!grfFlags
) /* enumerate internal data base of encodings */
1628 grfFlags
= MIMECONTF_MIME_LATEST
;
1630 ecp
= HeapAlloc( GetProcessHeap(), 0, sizeof (EnumCodePage_impl
) );
1631 ecp
->vtbl_IEnumCodePage
= &IEnumCodePage_vtbl
;
1635 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
1637 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
1639 if (mlang_data
[i
].mime_cp_info
[n
].flags
& grfFlags
)
1644 ecp
->cpinfo
= HeapAlloc(GetProcessHeap(), 0,
1645 sizeof(MIMECPINFO
) * ecp
->total
);
1646 cpinfo
= ecp
->cpinfo
;
1648 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
1650 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
1652 if (mlang_data
[i
].mime_cp_info
[n
].flags
& grfFlags
)
1653 fill_cp_info(&mlang_data
[i
], n
, cpinfo
++);
1657 TRACE("enumerated %d codepages with flags %08x\n", ecp
->total
, grfFlags
);
1659 *ppEnumCodePage
= (IEnumCodePage
*) ecp
;
1664 /******************************************************************************/
1666 typedef struct tagEnumScript_impl
1668 const IEnumScriptVtbl
*vtbl_IEnumScript
;
1670 SCRIPTINFO
*script_info
;
1674 static HRESULT WINAPI
fnIEnumScript_QueryInterface(
1679 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1681 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
1683 if (IsEqualGUID(riid
, &IID_IUnknown
)
1684 || IsEqualGUID(riid
, &IID_IEnumScript
))
1686 IEnumScript_AddRef(iface
);
1687 TRACE("Returning IID_IEnumScript %p ref = %d\n", This
, This
->ref
);
1688 *ppvObject
= &(This
->vtbl_IEnumScript
);
1692 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1693 return E_NOINTERFACE
;
1696 static ULONG WINAPI
fnIEnumScript_AddRef(
1699 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1700 return InterlockedIncrement(&This
->ref
);
1703 static ULONG WINAPI
fnIEnumScript_Release(
1706 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1707 ULONG ref
= InterlockedDecrement(&This
->ref
);
1709 TRACE("%p ref = %d\n", This
, ref
);
1712 TRACE("Destroying %p\n", This
);
1713 HeapFree(GetProcessHeap(), 0, This
->script_info
);
1714 HeapFree(GetProcessHeap(), 0, This
);
1720 static HRESULT WINAPI
fnIEnumScript_Clone(
1722 IEnumScript
** ppEnum
)
1724 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1725 FIXME("%p %p: stub!\n", This
, ppEnum
);
1729 static HRESULT WINAPI
fnIEnumScript_Next(
1733 ULONG
* pceltFetched
)
1735 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1736 TRACE("%p %u %p %p\n", This
, celt
, rgelt
, pceltFetched
);
1738 if (!pceltFetched
|| !rgelt
) return E_FAIL
;
1742 if (This
->pos
+ celt
> This
->total
)
1743 celt
= This
->total
- This
->pos
;
1745 if (!celt
) return S_FALSE
;
1747 memcpy(rgelt
, This
->script_info
+ This
->pos
, celt
* sizeof(SCRIPTINFO
));
1748 *pceltFetched
= celt
;
1754 static HRESULT WINAPI
fnIEnumScript_Reset(
1757 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1758 TRACE("%p\n", This
);
1764 static HRESULT WINAPI
fnIEnumScript_Skip(
1768 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1769 TRACE("%p %u\n", This
, celt
);
1771 if (celt
>= This
->total
) return S_FALSE
;
1777 static const IEnumScriptVtbl IEnumScript_vtbl
=
1779 fnIEnumScript_QueryInterface
,
1780 fnIEnumScript_AddRef
,
1781 fnIEnumScript_Release
,
1782 fnIEnumScript_Clone
,
1784 fnIEnumScript_Reset
,
1788 static HRESULT
EnumScript_create( MLang_impl
* mlang
, DWORD dwFlags
,
1789 LANGID LangId
, IEnumScript
** ppEnumScript
)
1791 EnumScript_impl
*es
;
1794 TRACE("%p, %08x, %04x, %p: stub!\n", mlang
, dwFlags
, LangId
, ppEnumScript
);
1796 if (!dwFlags
) /* enumerate all available scripts */
1797 dwFlags
= SCRIPTCONTF_SCRIPT_USER
| SCRIPTCONTF_SCRIPT_HIDE
| SCRIPTCONTF_SCRIPT_SYSTEM
;
1799 es
= HeapAlloc( GetProcessHeap(), 0, sizeof (EnumScript_impl
) );
1800 es
->vtbl_IEnumScript
= &IEnumScript_vtbl
;
1803 /* do not enumerate unicode flavours */
1804 es
->total
= sizeof(mlang_data
)/sizeof(mlang_data
[0]) - 1;
1805 es
->script_info
= HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPTINFO
) * es
->total
);
1807 for (i
= 0; i
< es
->total
; i
++)
1809 es
->script_info
[i
].ScriptId
= i
;
1810 es
->script_info
[i
].uiCodePage
= mlang_data
[i
].family_codepage
;
1811 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].description
, -1,
1812 es
->script_info
[i
].wszDescription
, MAX_SCRIPT_NAME
);
1813 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].fixed_font
, -1,
1814 es
->script_info
[i
].wszFixedWidthFont
, MAX_MIMEFACE_NAME
);
1815 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].proportional_font
, -1,
1816 es
->script_info
[i
].wszProportionalFont
, MAX_MIMEFACE_NAME
);
1819 TRACE("enumerated %d scripts with flags %08x\n", es
->total
, dwFlags
);
1821 *ppEnumScript
= (IEnumScript
*)es
;
1826 /******************************************************************************/
1828 static HRESULT WINAPI
fnIMLangFontLink_QueryInterface(
1829 IMLangFontLink
* iface
,
1833 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1834 return MLang_QueryInterface( This
, riid
, ppvObject
);
1837 static ULONG WINAPI
fnIMLangFontLink_AddRef(
1838 IMLangFontLink
* iface
)
1840 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1841 return MLang_AddRef( This
);
1844 static ULONG WINAPI
fnIMLangFontLink_Release(
1845 IMLangFontLink
* iface
)
1847 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1848 return MLang_Release( This
);
1851 static HRESULT WINAPI
fnIMLangFontLink_GetCharCodePages(
1852 IMLangFontLink
* iface
,
1854 DWORD
* pdwCodePages
)
1863 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
1865 WideCharToMultiByte(mlang_data
[i
].family_codepage
, WC_NO_BEST_FIT_CHARS
,
1866 &chSrc
, 1, &buf
, 1, NULL
, &used_dc
);
1868 /* If default char is not used, current codepage include the given symbol */
1871 IMLangFontLink_CodePageToCodePages(iface
,
1872 mlang_data
[i
].family_codepage
, &codePages
);
1873 *pdwCodePages
|= codePages
;
1879 static HRESULT WINAPI
fnIMLangFontLink_GetStrCodePages(
1880 IMLangFontLink
* iface
,
1881 const WCHAR
* pszSrc
,
1883 DWORD dwPriorityCodePages
,
1884 DWORD
* pdwCodePages
,
1885 long* pcchCodePages
)
1887 FIXME("(pszSrc=%s, cchSrc=%ld, dwPriorityCodePages=%d) stub\n", debugstr_w(pszSrc
), cchSrc
, dwPriorityCodePages
);
1893 static HRESULT WINAPI
fnIMLangFontLink_CodePageToCodePages(
1894 IMLangFontLink
* iface
,
1896 DWORD
* pdwCodePages
)
1898 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1902 TRACE("(%p) Seeking %u\n",This
, uCodePage
);
1904 rc
= TranslateCharsetInfo((DWORD
*)uCodePage
, &cs
, TCI_SRCCODEPAGE
);
1908 *pdwCodePages
= cs
.fs
.fsCsb
[0];
1909 TRACE("resulting CodePages 0x%x\n",*pdwCodePages
);
1913 TRACE("CodePage Not Found\n");
1918 static HRESULT WINAPI
fnIMLangFontLink_CodePagesToCodePage(
1919 IMLangFontLink
* iface
,
1921 UINT uDefaultCodePage
,
1924 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1925 DWORD mask
= 0x00000000;
1930 TRACE("(%p) scanning 0x%x default page %u\n",This
, dwCodePages
,
1933 *puCodePage
= 0x00000000;
1935 rc
= TranslateCharsetInfo((DWORD
*)uDefaultCodePage
, &cs
, TCI_SRCCODEPAGE
);
1937 if (rc
&& (dwCodePages
& cs
.fs
.fsCsb
[0]))
1939 TRACE("Found Default Codepage\n");
1940 *puCodePage
= uDefaultCodePage
;
1945 for (i
= 0; i
< 32; i
++)
1949 if (dwCodePages
& mask
)
1954 rc
= TranslateCharsetInfo(Csb
, &cs
, TCI_SRCFONTSIG
);
1958 TRACE("Falling back to least significant found CodePage %u\n",
1960 *puCodePage
= cs
.ciACP
;
1965 TRACE("no codepage found\n");
1969 static HRESULT WINAPI
fnIMLangFontLink_GetFontCodePages(
1970 IMLangFontLink
* iface
,
1973 DWORD
* pdwCodePages
)
1976 FONTSIGNATURE fontsig
;
1977 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1979 TRACE("(%p)\n",This
);
1981 old_font
= SelectObject(hDC
,hFont
);
1982 GetTextCharsetInfo(hDC
,&fontsig
, 0);
1983 SelectObject(hDC
,old_font
);
1985 *pdwCodePages
= fontsig
.fsCsb
[0];
1986 TRACE("CodePages is 0x%x\n",fontsig
.fsCsb
[0]);
1991 static HRESULT WINAPI
fnIMLangFontLink_MapFont(
1992 IMLangFontLink
* iface
,
2002 static HRESULT WINAPI
fnIMLangFontLink_ReleaseFont(
2003 IMLangFontLink
* iface
,
2010 static HRESULT WINAPI
fnIMLangFontLink_ResetFontMapping(
2011 IMLangFontLink
* iface
)
2018 static const IMLangFontLinkVtbl IMLangFontLink_vtbl
=
2020 fnIMLangFontLink_QueryInterface
,
2021 fnIMLangFontLink_AddRef
,
2022 fnIMLangFontLink_Release
,
2023 fnIMLangFontLink_GetCharCodePages
,
2024 fnIMLangFontLink_GetStrCodePages
,
2025 fnIMLangFontLink_CodePageToCodePages
,
2026 fnIMLangFontLink_CodePagesToCodePage
,
2027 fnIMLangFontLink_GetFontCodePages
,
2028 fnIMLangFontLink_MapFont
,
2029 fnIMLangFontLink_ReleaseFont
,
2030 fnIMLangFontLink_ResetFontMapping
,
2033 /******************************************************************************/
2035 static HRESULT WINAPI
fnIMultiLanguage_QueryInterface(
2036 IMultiLanguage
* iface
,
2040 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2041 return MLang_QueryInterface( This
, riid
, ppvObject
);
2044 static ULONG WINAPI
fnIMultiLanguage_AddRef( IMultiLanguage
* iface
)
2046 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2047 return IMLangFontLink_AddRef( ((IMLangFontLink
*)This
) );
2050 static ULONG WINAPI
fnIMultiLanguage_Release( IMultiLanguage
* iface
)
2052 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2053 return IMLangFontLink_Release( ((IMLangFontLink
*)This
) );
2056 static HRESULT WINAPI
fnIMultiLanguage_GetNumberOfCodePageInfo(
2057 IMultiLanguage
* iface
,
2064 static HRESULT WINAPI
fnIMultiLanguage_GetCodePageInfo(
2065 IMultiLanguage
* iface
,
2067 PMIMECPINFO pCodePageInfo
)
2071 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2072 TRACE("%p, %u, %p\n", This
, uiCodePage
, pCodePageInfo
);
2074 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2076 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2078 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
2080 fill_cp_info(&mlang_data
[i
], n
, pCodePageInfo
);
2089 static HRESULT WINAPI
fnIMultiLanguage_GetFamilyCodePage(
2090 IMultiLanguage
* iface
,
2092 UINT
* puiFamilyCodePage
)
2094 return GetFamilyCodePage(uiCodePage
, puiFamilyCodePage
);
2097 static HRESULT WINAPI
fnIMultiLanguage_EnumCodePages(
2098 IMultiLanguage
* iface
,
2100 IEnumCodePage
** ppEnumCodePage
)
2102 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2103 TRACE("%p %08x %p\n", This
, grfFlags
, ppEnumCodePage
);
2105 return EnumCodePage_create( This
, grfFlags
, 0, ppEnumCodePage
);
2108 static HRESULT WINAPI
fnIMultiLanguage_GetCharsetInfo(
2109 IMultiLanguage
* iface
,
2111 PMIMECSETINFO pCharsetInfo
)
2113 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2114 return IMultiLanguage3_GetCharsetInfo((IMultiLanguage3
*)&This
->vtbl_IMultiLanguage3
, Charset
, pCharsetInfo
);
2117 static HRESULT WINAPI
fnIMultiLanguage_IsConvertible(
2118 IMultiLanguage
* iface
,
2119 DWORD dwSrcEncoding
,
2120 DWORD dwDstEncoding
)
2122 return IsConvertINetStringAvailable(dwSrcEncoding
, dwDstEncoding
);
2125 static HRESULT WINAPI
fnIMultiLanguage_ConvertString(
2126 IMultiLanguage
* iface
,
2128 DWORD dwSrcEncoding
,
2129 DWORD dwDstEncoding
,
2135 return ConvertINetString(pdwMode
, dwSrcEncoding
, dwDstEncoding
,
2136 (LPCSTR
)pSrcStr
, (LPINT
)pcSrcSize
, (LPSTR
)pDstStr
, (LPINT
)pcDstSize
);
2139 static HRESULT WINAPI
fnIMultiLanguage_ConvertStringToUnicode(
2140 IMultiLanguage
* iface
,
2148 return ConvertINetMultiByteToUnicode(pdwMode
, dwEncoding
,
2149 (LPCSTR
)pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2152 static HRESULT WINAPI
fnIMultiLanguage_ConvertStringFromUnicode(
2153 IMultiLanguage
* iface
,
2161 return ConvertINetUnicodeToMultiByte(pdwMode
, dwEncoding
,
2162 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2165 static HRESULT WINAPI
fnIMultiLanguage_ConvertStringReset(
2166 IMultiLanguage
* iface
)
2172 static HRESULT WINAPI
fnIMultiLanguage_GetRfc1766FromLcid(
2173 IMultiLanguage
* iface
,
2177 WCHAR buf
[MAX_RFC1766_NAME
];
2179 TRACE("%p %04x %p\n", iface
, lcid
, pbstrRfc1766
);
2181 if (lcid_to_rfc1766W( lcid
, buf
, MAX_RFC1766_NAME
))
2183 *pbstrRfc1766
= SysAllocString( buf
);
2189 static HRESULT WINAPI
fnIMultiLanguage_GetLcidFromRfc1766(
2190 IMultiLanguage
* iface
,
2195 IEnumRfc1766
*rfc1766
;
2197 TRACE("%p %p %s\n", iface
, pLocale
, debugstr_w(bstrRfc1766
));
2199 if (!pLocale
|| !bstrRfc1766
)
2200 return E_INVALIDARG
;
2202 hr
= IMultiLanguage_EnumRfc1766(iface
, &rfc1766
);
2206 hr
= lcid_from_rfc1766(rfc1766
, pLocale
, bstrRfc1766
);
2208 IEnumRfc1766_Release(rfc1766
);
2212 /******************************************************************************/
2214 typedef struct tagEnumRfc1766_impl
2216 const IEnumRfc1766Vtbl
*vtbl_IEnumRfc1766
;
2222 static HRESULT WINAPI
fnIEnumRfc1766_QueryInterface(
2223 IEnumRfc1766
*iface
,
2227 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
2229 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
2231 if (IsEqualGUID(riid
, &IID_IUnknown
)
2232 || IsEqualGUID(riid
, &IID_IEnumRfc1766
))
2234 IEnumRfc1766_AddRef(iface
);
2235 TRACE("Returning IID_IEnumRfc1766 %p ref = %d\n", This
, This
->ref
);
2236 *ppvObject
= &(This
->vtbl_IEnumRfc1766
);
2240 WARN("(%p) -> (%s,%p), not found\n",This
,debugstr_guid(riid
),ppvObject
);
2241 return E_NOINTERFACE
;
2244 static ULONG WINAPI
fnIEnumRfc1766_AddRef(
2245 IEnumRfc1766
*iface
)
2247 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
2248 return InterlockedIncrement(&This
->ref
);
2251 static ULONG WINAPI
fnIEnumRfc1766_Release(
2252 IEnumRfc1766
*iface
)
2254 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
2255 ULONG ref
= InterlockedDecrement(&This
->ref
);
2257 TRACE("%p ref = %d\n", This
, ref
);
2260 TRACE("Destroying %p\n", This
);
2261 HeapFree(GetProcessHeap(), 0, This
->info
);
2262 HeapFree(GetProcessHeap(), 0, This
);
2267 static HRESULT WINAPI
fnIEnumRfc1766_Clone(
2268 IEnumRfc1766
*iface
,
2269 IEnumRfc1766
**ppEnum
)
2271 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
2272 FIXME("%p %p\n", This
, ppEnum
);
2276 static HRESULT WINAPI
fnIEnumRfc1766_Next(
2277 IEnumRfc1766
*iface
,
2280 ULONG
*pceltFetched
)
2284 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
2285 TRACE("%p %u %p %p\n", This
, celt
, rgelt
, pceltFetched
);
2287 if (!pceltFetched
) return S_FALSE
;
2290 if (!rgelt
) return S_FALSE
;
2292 if (This
->pos
+ celt
> This
->total
)
2293 celt
= This
->total
- This
->pos
;
2295 if (!celt
) return S_FALSE
;
2297 memcpy(rgelt
, This
->info
+ This
->pos
, celt
* sizeof(RFC1766INFO
));
2298 *pceltFetched
= celt
;
2301 for (i
= 0; i
< celt
; i
++)
2303 TRACE("#%u: %08x %s %s\n",
2305 wine_dbgstr_w(rgelt
[i
].wszRfc1766
),
2306 wine_dbgstr_w(rgelt
[i
].wszLocaleName
));
2311 static HRESULT WINAPI
fnIEnumRfc1766_Reset(
2312 IEnumRfc1766
*iface
)
2314 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
2315 TRACE("%p\n", This
);
2321 static HRESULT WINAPI
fnIEnumRfc1766_Skip(
2322 IEnumRfc1766
*iface
,
2325 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
2326 TRACE("%p %u\n", This
, celt
);
2328 if (celt
>= This
->total
) return S_FALSE
;
2334 static const IEnumRfc1766Vtbl IEnumRfc1766_vtbl
=
2336 fnIEnumRfc1766_QueryInterface
,
2337 fnIEnumRfc1766_AddRef
,
2338 fnIEnumRfc1766_Release
,
2339 fnIEnumRfc1766_Clone
,
2340 fnIEnumRfc1766_Next
,
2341 fnIEnumRfc1766_Reset
,
2345 struct enum_locales_data
2348 DWORD total
, allocated
;
2351 static BOOL CALLBACK
enum_locales_proc(LPWSTR locale
)
2354 struct enum_locales_data
*data
= TlsGetValue(MLANG_tls_index
);
2357 TRACE("%s\n", debugstr_w(locale
));
2359 if (data
->total
>= data
->allocated
)
2361 data
->allocated
+= 32;
2362 data
->info
= HeapReAlloc(GetProcessHeap(), 0, data
->info
, data
->allocated
* sizeof(RFC1766INFO
));
2363 if (!data
->info
) return FALSE
;
2366 info
= &data
->info
[data
->total
];
2368 info
->lcid
= strtolW(locale
, &end
, 16);
2369 if (*end
) /* invalid number */
2372 info
->wszRfc1766
[0] = 0;
2373 lcid_to_rfc1766W( info
->lcid
, info
->wszRfc1766
, MAX_RFC1766_NAME
);
2375 info
->wszLocaleName
[0] = 0;
2376 GetLocaleInfoW(info
->lcid
, LOCALE_SLANGUAGE
, info
->wszLocaleName
, MAX_LOCALE_NAME
);
2377 TRACE("ISO639: %s SLANGUAGE: %s\n", wine_dbgstr_w(info
->wszRfc1766
), wine_dbgstr_w(info
->wszLocaleName
));
2384 static HRESULT
EnumRfc1766_create(LANGID LangId
, IEnumRfc1766
**ppEnum
)
2386 EnumRfc1766_impl
*rfc
;
2387 struct enum_locales_data data
;
2389 TRACE("%04x, %p\n", LangId
, ppEnum
);
2391 rfc
= HeapAlloc( GetProcessHeap(), 0, sizeof(EnumRfc1766_impl
) );
2392 rfc
->vtbl_IEnumRfc1766
= &IEnumRfc1766_vtbl
;
2398 data
.allocated
= 32;
2399 data
.info
= HeapAlloc(GetProcessHeap(), 0, data
.allocated
* sizeof(RFC1766INFO
));
2402 HeapFree(GetProcessHeap(), 0, rfc
);
2406 TlsSetValue(MLANG_tls_index
, &data
);
2407 EnumSystemLocalesW(enum_locales_proc
, 0/*LOCALE_SUPPORTED*/);
2408 TlsSetValue(MLANG_tls_index
, NULL
);
2410 TRACE("enumerated %d rfc1766 structures\n", data
.total
);
2414 HeapFree(GetProcessHeap(), 0, data
.info
);
2415 HeapFree(GetProcessHeap(), 0, rfc
);
2419 rfc
->info
= data
.info
;
2420 rfc
->total
= data
.total
;
2422 *ppEnum
= (IEnumRfc1766
*)rfc
;
2426 static HRESULT WINAPI
fnIMultiLanguage_EnumRfc1766(
2427 IMultiLanguage
*iface
,
2428 IEnumRfc1766
**ppEnumRfc1766
)
2430 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2431 TRACE("%p %p\n", This
, ppEnumRfc1766
);
2433 return EnumRfc1766_create(0, ppEnumRfc1766
);
2436 /******************************************************************************/
2438 static HRESULT WINAPI
fnIMultiLanguage_GetRfc1766Info(
2439 IMultiLanguage
* iface
,
2441 PRFC1766INFO pRfc1766Info
)
2447 static HRESULT WINAPI
fnIMultiLanguage_CreateConvertCharset(
2448 IMultiLanguage
* iface
,
2452 IMLangConvertCharset
** ppMLangConvertCharset
)
2458 static const IMultiLanguageVtbl IMultiLanguage_vtbl
=
2460 fnIMultiLanguage_QueryInterface
,
2461 fnIMultiLanguage_AddRef
,
2462 fnIMultiLanguage_Release
,
2463 fnIMultiLanguage_GetNumberOfCodePageInfo
,
2464 fnIMultiLanguage_GetCodePageInfo
,
2465 fnIMultiLanguage_GetFamilyCodePage
,
2466 fnIMultiLanguage_EnumCodePages
,
2467 fnIMultiLanguage_GetCharsetInfo
,
2468 fnIMultiLanguage_IsConvertible
,
2469 fnIMultiLanguage_ConvertString
,
2470 fnIMultiLanguage_ConvertStringToUnicode
,
2471 fnIMultiLanguage_ConvertStringFromUnicode
,
2472 fnIMultiLanguage_ConvertStringReset
,
2473 fnIMultiLanguage_GetRfc1766FromLcid
,
2474 fnIMultiLanguage_GetLcidFromRfc1766
,
2475 fnIMultiLanguage_EnumRfc1766
,
2476 fnIMultiLanguage_GetRfc1766Info
,
2477 fnIMultiLanguage_CreateConvertCharset
,
2481 /******************************************************************************/
2483 static HRESULT WINAPI
fnIMultiLanguage2_QueryInterface(
2484 IMultiLanguage3
* iface
,
2488 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2489 return MLang_QueryInterface( This
, riid
, ppvObject
);
2492 static ULONG WINAPI
fnIMultiLanguage2_AddRef( IMultiLanguage3
* iface
)
2494 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2495 return MLang_AddRef( This
);
2498 static ULONG WINAPI
fnIMultiLanguage2_Release( IMultiLanguage3
* iface
)
2500 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2501 return MLang_Release( This
);
2504 static HRESULT WINAPI
fnIMultiLanguage2_GetNumberOfCodePageInfo(
2505 IMultiLanguage3
* iface
,
2508 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2509 TRACE("%p, %p\n", This
, pcCodePage
);
2511 if (!pcCodePage
) return S_FALSE
;
2513 *pcCodePage
= This
->total_cp
;
2517 static void fill_cp_info(const struct mlang_data
*ml_data
, UINT index
, MIMECPINFO
*mime_cp_info
)
2521 if (TranslateCharsetInfo((DWORD
*)ml_data
->family_codepage
, &csi
, TCI_SRCCODEPAGE
))
2522 mime_cp_info
->bGDICharset
= csi
.ciCharset
;
2524 mime_cp_info
->bGDICharset
= DEFAULT_CHARSET
;
2526 mime_cp_info
->dwFlags
= ml_data
->mime_cp_info
[index
].flags
;
2527 mime_cp_info
->uiCodePage
= ml_data
->mime_cp_info
[index
].cp
;
2528 mime_cp_info
->uiFamilyCodePage
= ml_data
->family_codepage
;
2529 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].description
, -1,
2530 mime_cp_info
->wszDescription
, sizeof(mime_cp_info
->wszDescription
)/sizeof(WCHAR
));
2531 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].web_charset
, -1,
2532 mime_cp_info
->wszWebCharset
, sizeof(mime_cp_info
->wszWebCharset
)/sizeof(WCHAR
));
2533 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].header_charset
, -1,
2534 mime_cp_info
->wszHeaderCharset
, sizeof(mime_cp_info
->wszHeaderCharset
)/sizeof(WCHAR
));
2535 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].body_charset
, -1,
2536 mime_cp_info
->wszBodyCharset
, sizeof(mime_cp_info
->wszBodyCharset
)/sizeof(WCHAR
));
2538 MultiByteToWideChar(CP_ACP
, 0, ml_data
->fixed_font
, -1,
2539 mime_cp_info
->wszFixedWidthFont
, sizeof(mime_cp_info
->wszFixedWidthFont
)/sizeof(WCHAR
));
2540 MultiByteToWideChar(CP_ACP
, 0, ml_data
->proportional_font
, -1,
2541 mime_cp_info
->wszProportionalFont
, sizeof(mime_cp_info
->wszProportionalFont
)/sizeof(WCHAR
));
2543 TRACE("%08x %u %u %s %s %s %s %s %s %d\n",
2544 mime_cp_info
->dwFlags
, mime_cp_info
->uiCodePage
,
2545 mime_cp_info
->uiFamilyCodePage
,
2546 wine_dbgstr_w(mime_cp_info
->wszDescription
),
2547 wine_dbgstr_w(mime_cp_info
->wszWebCharset
),
2548 wine_dbgstr_w(mime_cp_info
->wszHeaderCharset
),
2549 wine_dbgstr_w(mime_cp_info
->wszBodyCharset
),
2550 wine_dbgstr_w(mime_cp_info
->wszFixedWidthFont
),
2551 wine_dbgstr_w(mime_cp_info
->wszProportionalFont
),
2552 mime_cp_info
->bGDICharset
);
2555 static HRESULT WINAPI
fnIMultiLanguage2_GetCodePageInfo(
2556 IMultiLanguage3
* iface
,
2559 PMIMECPINFO pCodePageInfo
)
2563 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2564 TRACE("%p, %u, %04x, %p\n", This
, uiCodePage
, LangId
, pCodePageInfo
);
2566 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2568 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2570 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
2572 fill_cp_info(&mlang_data
[i
], n
, pCodePageInfo
);
2581 static HRESULT WINAPI
fnIMultiLanguage2_GetFamilyCodePage(
2582 IMultiLanguage3
* iface
,
2584 UINT
* puiFamilyCodePage
)
2586 return GetFamilyCodePage(uiCodePage
, puiFamilyCodePage
);
2589 static HRESULT WINAPI
fnIMultiLanguage2_EnumCodePages(
2590 IMultiLanguage3
* iface
,
2593 IEnumCodePage
** ppEnumCodePage
)
2595 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2596 TRACE("%p %08x %04x %p\n", This
, grfFlags
, LangId
, ppEnumCodePage
);
2598 return EnumCodePage_create( This
, grfFlags
, LangId
, ppEnumCodePage
);
2601 static HRESULT WINAPI
fnIMultiLanguage2_GetCharsetInfo(
2602 IMultiLanguage3
* iface
,
2604 PMIMECSETINFO pCharsetInfo
)
2608 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2609 TRACE("%p %s %p\n", This
, debugstr_w(Charset
), pCharsetInfo
);
2611 if (!pCharsetInfo
) return E_FAIL
;
2613 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2615 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2617 WCHAR csetW
[MAX_MIMECSET_NAME
];
2619 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].mime_cp_info
[n
].web_charset
, -1, csetW
, MAX_MIMECSET_NAME
);
2620 if (!lstrcmpiW(Charset
, csetW
))
2622 pCharsetInfo
->uiCodePage
= mlang_data
[i
].family_codepage
;
2623 pCharsetInfo
->uiInternetEncoding
= mlang_data
[i
].mime_cp_info
[n
].cp
;
2624 strcpyW(pCharsetInfo
->wszCharset
, csetW
);
2631 * Since we do not support charsets like iso-2022-jp and do not have
2632 * them in our database as a primary (web_charset) encoding this loop
2633 * does an attempt to 'approximate' charset name by header_charset.
2635 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2637 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2639 WCHAR csetW
[MAX_MIMECSET_NAME
];
2641 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].mime_cp_info
[n
].header_charset
, -1, csetW
, MAX_MIMECSET_NAME
);
2642 if (!lstrcmpiW(Charset
, csetW
))
2644 pCharsetInfo
->uiCodePage
= mlang_data
[i
].family_codepage
;
2645 pCharsetInfo
->uiInternetEncoding
= mlang_data
[i
].mime_cp_info
[n
].cp
;
2646 strcpyW(pCharsetInfo
->wszCharset
, csetW
);
2655 static HRESULT WINAPI
fnIMultiLanguage2_IsConvertible(
2656 IMultiLanguage3
* iface
,
2657 DWORD dwSrcEncoding
,
2658 DWORD dwDstEncoding
)
2660 return IsConvertINetStringAvailable(dwSrcEncoding
, dwDstEncoding
);
2663 static HRESULT WINAPI
fnIMultiLanguage2_ConvertString(
2664 IMultiLanguage3
* iface
,
2666 DWORD dwSrcEncoding
,
2667 DWORD dwDstEncoding
,
2673 return ConvertINetString(pdwMode
, dwSrcEncoding
, dwDstEncoding
,
2674 (LPCSTR
)pSrcStr
, (LPINT
)pcSrcSize
, (LPSTR
)pDstStr
, (LPINT
)pcDstSize
);
2677 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringToUnicode(
2678 IMultiLanguage3
* iface
,
2686 return ConvertINetMultiByteToUnicode(pdwMode
, dwEncoding
,
2687 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2690 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringFromUnicode(
2691 IMultiLanguage3
* iface
,
2699 return ConvertINetUnicodeToMultiByte(pdwMode
, dwEncoding
,
2700 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2703 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringReset(
2704 IMultiLanguage3
* iface
)
2710 static HRESULT WINAPI
fnIMultiLanguage2_GetRfc1766FromLcid(
2711 IMultiLanguage3
* iface
,
2715 WCHAR buf
[MAX_RFC1766_NAME
];
2717 TRACE("%p %04x %p\n", iface
, lcid
, pbstrRfc1766
);
2719 if (lcid_to_rfc1766W( lcid
, buf
, MAX_RFC1766_NAME
))
2721 *pbstrRfc1766
= SysAllocString( buf
);
2727 static HRESULT WINAPI
fnIMultiLanguage2_GetLcidFromRfc1766(
2728 IMultiLanguage3
* iface
,
2733 IEnumRfc1766
*rfc1766
;
2735 TRACE("%p %p %s\n", iface
, pLocale
, debugstr_w(bstrRfc1766
));
2737 if (!pLocale
|| !bstrRfc1766
)
2738 return E_INVALIDARG
;
2740 hr
= IMultiLanguage2_EnumRfc1766(iface
, 0, &rfc1766
);
2744 hr
= lcid_from_rfc1766(rfc1766
, pLocale
, bstrRfc1766
);
2746 IEnumRfc1766_Release(rfc1766
);
2750 static HRESULT WINAPI
fnIMultiLanguage2_EnumRfc1766(
2751 IMultiLanguage3
* iface
,
2753 IEnumRfc1766
** ppEnumRfc1766
)
2755 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2756 TRACE("%p %p\n", This
, ppEnumRfc1766
);
2758 return EnumRfc1766_create(LangId
, ppEnumRfc1766
);
2761 static HRESULT WINAPI
fnIMultiLanguage2_GetRfc1766Info(
2762 IMultiLanguage3
* iface
,
2765 PRFC1766INFO pRfc1766Info
)
2771 static HRESULT WINAPI
fnIMultiLanguage2_CreateConvertCharset(
2772 IMultiLanguage3
* iface
,
2776 IMLangConvertCharset
** ppMLangConvertCharset
)
2782 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringInIStream(
2783 IMultiLanguage3
* iface
,
2787 DWORD dwSrcEncoding
,
2788 DWORD dwDstEncoding
,
2792 char *src
, *dst
= NULL
;
2797 TRACE("%p %0x8 %s %u %u %p %p\n",
2798 pdwMode
, dwFlag
, debugstr_w(lpFallBack
), dwSrcEncoding
, dwDstEncoding
, pstmIn
, pstmOut
);
2800 FIXME("dwFlag and lpFallBack not handled\n");
2802 hr
= IStream_Stat(pstmIn
, &stat
, STATFLAG_NONAME
);
2803 if (FAILED(hr
)) return hr
;
2805 if (stat
.cbSize
.QuadPart
> MAXLONG
) return E_INVALIDARG
;
2806 if (!(src
= HeapAlloc(GetProcessHeap(), 0, stat
.cbSize
.QuadPart
))) return E_OUTOFMEMORY
;
2808 hr
= IStream_Read(pstmIn
, src
, stat
.cbSize
.QuadPart
, (ULONG
*)&srclen
);
2809 if (FAILED(hr
)) goto exit
;
2811 hr
= ConvertINetString(pdwMode
, dwSrcEncoding
, dwDstEncoding
, src
, &srclen
, NULL
, &dstlen
);
2812 if (FAILED(hr
)) goto exit
;
2814 if (!(dst
= HeapAlloc(GetProcessHeap(), 0, dstlen
)))
2819 hr
= ConvertINetString(pdwMode
, dwSrcEncoding
, dwDstEncoding
, src
, &srclen
, dst
, &dstlen
);
2820 if (FAILED(hr
)) goto exit
;
2822 hr
= IStream_Write(pstmOut
, dst
, dstlen
, NULL
);
2825 HeapFree(GetProcessHeap(), 0, src
);
2826 HeapFree(GetProcessHeap(), 0, dst
);
2831 * TODO: handle dwFlag and lpFallBack
2833 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringToUnicodeEx(
2834 IMultiLanguage3
* iface
,
2845 return ConvertINetMultiByteToUnicode(pdwMode
, dwEncoding
,
2846 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2849 /*****************************************************************************
2850 * MultiLanguage2::ConvertStringToUnicodeEx
2852 * Translates the multibyte string from the specified code page to Unicode.
2855 * see ConvertStringToUnicode
2857 * lpFallBack if dwFlag contains MLCONVCHARF_USEDEFCHAR, lpFallBack string used
2858 * instead unconvertible characters.
2862 * S_FALSE The conversion is not supported.
2863 * E_FAIL Some error has occurred.
2865 * TODO: handle dwFlag and lpFallBack
2867 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringFromUnicodeEx(
2868 IMultiLanguage3
* This
,
2879 return ConvertINetUnicodeToMultiByte(pdwMode
, dwEncoding
,
2880 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2883 static HRESULT WINAPI
fnIMultiLanguage2_DetectCodepageInIStream(
2884 IMultiLanguage3
* iface
,
2886 DWORD dwPrefWinCodePage
,
2888 DetectEncodingInfo
* lpEncoding
,
2895 static HRESULT WINAPI
fnIMultiLanguage2_DetectInputCodepage(
2896 IMultiLanguage3
* iface
,
2898 DWORD dwPrefWinCodePage
,
2901 DetectEncodingInfo
* lpEncoding
,
2908 static HRESULT WINAPI
fnIMultiLanguage2_ValidateCodePage(
2909 IMultiLanguage3
* iface
,
2913 FIXME("%u, %p\n", uiCodePage
, hwnd
);
2917 static HRESULT WINAPI
fnIMultiLanguage2_GetCodePageDescription(
2918 IMultiLanguage3
* iface
,
2921 LPWSTR lpWideCharStr
,
2924 /* Find first instance */
2927 TRACE ("%u, %04x, %p, %d\n", uiCodePage
, lcid
, lpWideCharStr
, cchWideChar
);
2928 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2930 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2932 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
2934 MultiByteToWideChar(CP_ACP
, 0,
2935 mlang_data
[i
].mime_cp_info
[n
].description
,
2936 -1, lpWideCharStr
, cchWideChar
);
2945 static HRESULT WINAPI
fnIMultiLanguage2_IsCodePageInstallable(
2946 IMultiLanguage3
* iface
,
2949 FIXME("%u\n", uiCodePage
);
2953 static HRESULT WINAPI
fnIMultiLanguage2_SetMimeDBSource(
2954 IMultiLanguage3
* iface
,
2957 FIXME("0x%08x\n", dwSource
);
2961 static HRESULT WINAPI
fnIMultiLanguage2_GetNumberOfScripts(
2962 IMultiLanguage3
* iface
,
2965 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2966 TRACE("%p %p\n", This
, pnScripts
);
2968 if (!pnScripts
) return S_FALSE
;
2970 *pnScripts
= This
->total_scripts
;
2974 static HRESULT WINAPI
fnIMultiLanguage2_EnumScripts(
2975 IMultiLanguage3
* iface
,
2978 IEnumScript
** ppEnumScript
)
2980 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2981 TRACE("%p %08x %04x %p\n", This
, dwFlags
, LangId
, ppEnumScript
);
2983 return EnumScript_create( This
, dwFlags
, LangId
, ppEnumScript
);
2986 static HRESULT WINAPI
fnIMultiLanguage2_ValidateCodePageEx(
2987 IMultiLanguage3
* iface
,
2990 DWORD dwfIODControl
)
2992 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2993 FIXME("%p %u %p %08x: stub!\n", This
, uiCodePage
, hwnd
, dwfIODControl
);
2998 static HRESULT WINAPI
fnIMultiLanguage3_DetectOutboundCodePage(
2999 IMultiLanguage3
*iface
,
3001 LPCWSTR lpWideCharStr
,
3003 UINT
*puiPreferredCodePages
,
3004 UINT nPreferredCodePages
,
3005 UINT
*puiDetectedCodePages
,
3006 UINT
*pnDetectedCodePages
,
3007 WCHAR
*lpSpecialChar
)
3009 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
3010 FIXME("(%p)->(%08x %s %u %p %u %p %p %p)\n", This
, dwFlags
, debugstr_w(lpWideCharStr
),
3011 cchWideChar
, puiPreferredCodePages
, nPreferredCodePages
, puiDetectedCodePages
,
3012 pnDetectedCodePages
, lpSpecialChar
);
3016 static HRESULT WINAPI
fnIMultiLanguage3_DetectOutboundCodePageInIStream(
3017 IMultiLanguage3
*iface
,
3020 UINT
*puiPreferredCodePages
,
3021 UINT nPreferredCodePages
,
3022 UINT
*puiDetectedCodePages
,
3023 UINT
*pnDetectedCodePages
,
3024 WCHAR
*lpSpecialChar
)
3026 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
3027 FIXME("(%p)->(%08x %p %p %u %p %p %p)\n", This
, dwFlags
, pStrIn
,
3028 puiPreferredCodePages
, nPreferredCodePages
, puiDetectedCodePages
,
3029 pnDetectedCodePages
, lpSpecialChar
);
3033 static const IMultiLanguage3Vtbl IMultiLanguage3_vtbl
=
3035 fnIMultiLanguage2_QueryInterface
,
3036 fnIMultiLanguage2_AddRef
,
3037 fnIMultiLanguage2_Release
,
3038 fnIMultiLanguage2_GetNumberOfCodePageInfo
,
3039 fnIMultiLanguage2_GetCodePageInfo
,
3040 fnIMultiLanguage2_GetFamilyCodePage
,
3041 fnIMultiLanguage2_EnumCodePages
,
3042 fnIMultiLanguage2_GetCharsetInfo
,
3043 fnIMultiLanguage2_IsConvertible
,
3044 fnIMultiLanguage2_ConvertString
,
3045 fnIMultiLanguage2_ConvertStringToUnicode
,
3046 fnIMultiLanguage2_ConvertStringFromUnicode
,
3047 fnIMultiLanguage2_ConvertStringReset
,
3048 fnIMultiLanguage2_GetRfc1766FromLcid
,
3049 fnIMultiLanguage2_GetLcidFromRfc1766
,
3050 fnIMultiLanguage2_EnumRfc1766
,
3051 fnIMultiLanguage2_GetRfc1766Info
,
3052 fnIMultiLanguage2_CreateConvertCharset
,
3053 fnIMultiLanguage2_ConvertStringInIStream
,
3054 fnIMultiLanguage2_ConvertStringToUnicodeEx
,
3055 fnIMultiLanguage2_ConvertStringFromUnicodeEx
,
3056 fnIMultiLanguage2_DetectCodepageInIStream
,
3057 fnIMultiLanguage2_DetectInputCodepage
,
3058 fnIMultiLanguage2_ValidateCodePage
,
3059 fnIMultiLanguage2_GetCodePageDescription
,
3060 fnIMultiLanguage2_IsCodePageInstallable
,
3061 fnIMultiLanguage2_SetMimeDBSource
,
3062 fnIMultiLanguage2_GetNumberOfScripts
,
3063 fnIMultiLanguage2_EnumScripts
,
3064 fnIMultiLanguage2_ValidateCodePageEx
,
3065 fnIMultiLanguage3_DetectOutboundCodePage
,
3066 fnIMultiLanguage3_DetectOutboundCodePageInIStream
3069 /******************************************************************************/
3070 static HRESULT WINAPI
fnIMLangFontLink2_QueryInterface(
3071 IMLangFontLink2
* iface
,
3075 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink2
, iface
);
3076 return MLang_QueryInterface( This
, riid
, ppvObject
);
3079 static ULONG WINAPI
fnIMLangFontLink2_AddRef( IMLangFontLink2
* iface
)
3081 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink2
, iface
);
3082 return MLang_AddRef( This
);
3085 static ULONG WINAPI
fnIMLangFontLink2_Release( IMLangFontLink2
* iface
)
3087 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink2
, iface
);
3088 return MLang_Release( This
);
3091 static HRESULT WINAPI
fnIMLangFontLink2_GetCharCodePages( IMLangFontLink2
* This
,
3092 WCHAR chSrc
, DWORD
*pdwCodePages
)
3094 FIXME("(%p)->%s %p\n",This
, debugstr_wn(&chSrc
,1),pdwCodePages
);
3098 static HRESULT WINAPI
fnIMLangFontLink2_GetStrCodePages( IMLangFontLink2
* This
,
3099 const WCHAR
*pszSrc
, long cchSrc
, DWORD dwPriorityCodePages
,
3100 DWORD
*pdwCodePages
, long *pcchCodePages
)
3102 FIXME("(%p)->%s %li %x %p %p\n",This
, debugstr_wn(pszSrc
,cchSrc
),cchSrc
,dwPriorityCodePages
,pdwCodePages
,pcchCodePages
);
3108 static HRESULT WINAPI
fnIMLangFontLink2_CodePageToCodePages(IMLangFontLink2
* This
,
3110 DWORD
*pdwCodePages
)
3112 FIXME("(%p)->%i %p\n",This
, uCodePage
, pdwCodePages
);
3116 static HRESULT WINAPI
fnIMLangFontLink2_CodePagesToCodePage(IMLangFontLink2
* This
,
3117 DWORD dwCodePages
, UINT uDefaultCodePage
, UINT
*puCodePage
)
3119 FIXME("(%p)->%i %i %p\n",This
, dwCodePages
, uDefaultCodePage
, puCodePage
);
3123 static HRESULT WINAPI
fnIMLangFontLink2_GetFontCodePages(IMLangFontLink2
* This
,
3124 HDC hDC
, HFONT hFont
, DWORD
*pdwCodePages
)
3126 FIXME("(%p)->%p %p %p\n",This
, hDC
, hFont
, pdwCodePages
);
3130 static HRESULT WINAPI
fnIMLangFontLink2_ReleaseFont(IMLangFontLink2
* This
,
3133 FIXME("(%p)->%p\n",This
, hFont
);
3137 static HRESULT WINAPI
fnIMLangFontLink2_ResetFontMapping(IMLangFontLink2
* This
)
3139 FIXME("(%p)->\n",This
);
3143 static HRESULT WINAPI
fnIMLangFontLink2_MapFont(IMLangFontLink2
* This
,
3144 HDC hDC
, DWORD dwCodePages
, WCHAR chSrc
, HFONT
*pFont
)
3146 FIXME("(%p)->%p %i %s %p\n",This
, hDC
, dwCodePages
, debugstr_wn(&chSrc
,1), pFont
);
3150 static HRESULT WINAPI
fnIMLangFontLink2_GetFontUnicodeRanges(IMLangFontLink2
* This
,
3151 HDC hDC
, UINT
*puiRanges
, UNICODERANGE
*pUranges
)
3153 FIXME("(%p)->%p %p %p\n",This
, hDC
, puiRanges
, pUranges
);
3157 static HRESULT WINAPI
fnIMLangFontLink2_GetScriptFontInfo(IMLangFontLink2
* This
,
3158 SCRIPT_ID sid
, DWORD dwFlags
, UINT
*puiFonts
,
3159 SCRIPTFONTINFO
*pScriptFont
)
3161 FIXME("(%p)->%i %i %p %p\n",This
, sid
, dwFlags
, puiFonts
, pScriptFont
);
3165 static HRESULT WINAPI
fnIMLangFontLink2_CodePageToScriptID(IMLangFontLink2
* This
,
3166 UINT uiCodePage
, SCRIPT_ID
*pSid
)
3168 FIXME("(%p)->%i %p\n",This
, uiCodePage
, pSid
);
3172 static const IMLangFontLink2Vtbl IMLangFontLink2_vtbl
=
3174 fnIMLangFontLink2_QueryInterface
,
3175 fnIMLangFontLink2_AddRef
,
3176 fnIMLangFontLink2_Release
,
3177 fnIMLangFontLink2_GetCharCodePages
,
3178 fnIMLangFontLink2_GetStrCodePages
,
3179 fnIMLangFontLink2_CodePageToCodePages
,
3180 fnIMLangFontLink2_CodePagesToCodePage
,
3181 fnIMLangFontLink2_GetFontCodePages
,
3182 fnIMLangFontLink2_ReleaseFont
,
3183 fnIMLangFontLink2_ResetFontMapping
,
3184 fnIMLangFontLink2_MapFont
,
3185 fnIMLangFontLink2_GetFontUnicodeRanges
,
3186 fnIMLangFontLink2_GetScriptFontInfo
,
3187 fnIMLangFontLink2_CodePageToScriptID
3190 /******************************************************************************/
3192 static HRESULT WINAPI
fnIMLangLineBreakConsole_QueryInterface(
3193 IMLangLineBreakConsole
* iface
,
3197 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangLineBreakConsole
, iface
);
3198 return MLang_QueryInterface( This
, riid
, ppvObject
);
3201 static ULONG WINAPI
fnIMLangLineBreakConsole_AddRef(
3202 IMLangLineBreakConsole
* iface
)
3204 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangLineBreakConsole
, iface
);
3205 return MLang_AddRef( This
);
3208 static ULONG WINAPI
fnIMLangLineBreakConsole_Release(
3209 IMLangLineBreakConsole
* iface
)
3211 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangLineBreakConsole
, iface
);
3212 return MLang_Release( This
);
3215 static HRESULT WINAPI
fnIMLangLineBreakConsole_BreakLineML(
3216 IMLangLineBreakConsole
* iface
,
3217 IMLangString
* pSrcMLStr
,
3225 FIXME("(%p)->%p %li %li %li %li %p %p\n", iface
, pSrcMLStr
, lSrcPos
, lSrcLen
, cMinColumns
, cMaxColumns
, plLineLen
, plSkipLen
);
3229 static HRESULT WINAPI
fnIMLangLineBreakConsole_BreakLineW(
3230 IMLangLineBreakConsole
* iface
,
3232 const WCHAR
* pszSrc
,
3238 FIXME("(%p)->%i %s %li %li %p %p\n", iface
, locale
, debugstr_wn(pszSrc
,cchSrc
), cchSrc
, cMaxColumns
, pcchLine
, pcchSkip
);
3245 static HRESULT WINAPI
fnIMLangLineBreakConsole_BreakLineA(
3246 IMLangLineBreakConsole
* iface
,
3255 FIXME("(%p)->%i %i %s %li %li %p %p\n", iface
, locale
, uCodePage
, debugstr_an(pszSrc
,cchSrc
), cchSrc
, cMaxColumns
, pcchLine
, pcchSkip
);
3262 static const IMLangLineBreakConsoleVtbl IMLangLineBreakConsole_vtbl
=
3264 fnIMLangLineBreakConsole_QueryInterface
,
3265 fnIMLangLineBreakConsole_AddRef
,
3266 fnIMLangLineBreakConsole_Release
,
3267 fnIMLangLineBreakConsole_BreakLineML
,
3268 fnIMLangLineBreakConsole_BreakLineW
,
3269 fnIMLangLineBreakConsole_BreakLineA
3272 static HRESULT
MultiLanguage_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
3277 TRACE("Creating MultiLanguage object\n");
3280 return CLASS_E_NOAGGREGATION
;
3282 mlang
= HeapAlloc( GetProcessHeap(), 0, sizeof (MLang_impl
) );
3283 mlang
->vtbl_IMLangFontLink
= &IMLangFontLink_vtbl
;
3284 mlang
->vtbl_IMultiLanguage
= &IMultiLanguage_vtbl
;
3285 mlang
->vtbl_IMultiLanguage3
= &IMultiLanguage3_vtbl
;
3286 mlang
->vtbl_IMLangFontLink2
= &IMLangFontLink2_vtbl
;
3287 mlang
->vtbl_IMLangLineBreakConsole
= &IMLangLineBreakConsole_vtbl
;
3289 mlang
->total_cp
= 0;
3290 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
3291 mlang
->total_cp
+= mlang_data
[i
].number_of_cp
;
3293 /* do not enumerate unicode flavours */
3294 mlang
->total_scripts
= sizeof(mlang_data
)/sizeof(mlang_data
[0]) - 1;
3298 TRACE("returning %p\n", mlang
);
3305 /******************************************************************************/
3307 HRESULT WINAPI
DllCanUnloadNow(void)
3309 return dll_count
== 0 ? S_OK
: S_FALSE
;
3312 HRESULT WINAPI
GetGlobalFontLinkObject(void)