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
= min(size
, destsz
);
1003 size
= ConvertJapaneseUnicodeToJIS(pSrcStr
, *pcSrcSize
, pDstStr
,
1012 size
= WideCharToMultiByte(dwEncoding
, 0, pSrcStr
, *pcSrcSize
,
1013 NULL
, 0, NULL
, NULL
);
1019 size
= min(size
, destsz
);
1020 size
= WideCharToMultiByte(dwEncoding
, 0, pSrcStr
, *pcSrcSize
,
1021 pDstStr
, destsz
, NULL
, NULL
);
1036 HRESULT WINAPI
ConvertINetString(
1038 DWORD dwSrcEncoding
,
1039 DWORD dwDstEncoding
,
1046 TRACE("%p %d %d %s %p %p %p\n", pdwMode
, dwSrcEncoding
, dwDstEncoding
,
1047 debugstr_a(pSrcStr
), pcSrcSize
, pDstStr
, pcDstSize
);
1049 if (dwSrcEncoding
== CP_UNICODE
)
1052 if (pcSrcSize
&& *pcSrcSize
!= -1)
1054 cSrcSizeW
= *pcSrcSize
/ sizeof(WCHAR
);
1055 pcSrcSize
= &cSrcSizeW
;
1057 return ConvertINetUnicodeToMultiByte(pdwMode
, dwDstEncoding
, (LPCWSTR
)pSrcStr
, pcSrcSize
, pDstStr
, pcDstSize
);
1059 else if (dwDstEncoding
== CP_UNICODE
)
1061 HRESULT hr
= ConvertINetMultiByteToUnicode(pdwMode
, dwSrcEncoding
, pSrcStr
, pcSrcSize
, (LPWSTR
)pDstStr
, pcDstSize
);
1062 *pcDstSize
*= sizeof(WCHAR
);
1071 TRACE("convert %s from %d to %d\n", debugstr_a(pSrcStr
), dwSrcEncoding
, dwDstEncoding
);
1073 hr
= ConvertINetMultiByteToUnicode(pdwMode
, dwSrcEncoding
, pSrcStr
, pcSrcSize
, NULL
, &cDstSizeW
);
1077 pDstStrW
= HeapAlloc(GetProcessHeap(), 0, cDstSizeW
* sizeof(WCHAR
));
1078 hr
= ConvertINetMultiByteToUnicode(pdwMode
, dwSrcEncoding
, pSrcStr
, pcSrcSize
, pDstStrW
, &cDstSizeW
);
1080 hr
= ConvertINetUnicodeToMultiByte(pdwMode
, dwDstEncoding
, pDstStrW
, &cDstSizeW
, pDstStr
, pcDstSize
);
1082 HeapFree(GetProcessHeap(), 0, pDstStrW
);
1087 static HRESULT
GetFamilyCodePage(
1089 UINT
* puiFamilyCodePage
)
1093 TRACE("%u %p\n", uiCodePage
, puiFamilyCodePage
);
1095 if (!puiFamilyCodePage
) return S_FALSE
;
1097 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
1099 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
1101 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
1103 *puiFamilyCodePage
= mlang_data
[i
].family_codepage
;
1112 HRESULT WINAPI
IsConvertINetStringAvailable(
1113 DWORD dwSrcEncoding
,
1114 DWORD dwDstEncoding
)
1116 UINT src_family
, dst_family
;
1118 TRACE("%d %d\n", dwSrcEncoding
, dwDstEncoding
);
1120 if (GetFamilyCodePage(dwSrcEncoding
, &src_family
) != S_OK
||
1121 GetFamilyCodePage(dwDstEncoding
, &dst_family
) != S_OK
)
1124 if (src_family
== dst_family
) return S_OK
;
1126 /* we can convert any codepage to/from unicode */
1127 if (src_family
== CP_UNICODE
|| dst_family
== CP_UNICODE
) return S_OK
;
1132 static inline INT
lcid_to_rfc1766A( LCID lcid
, LPSTR rfc1766
, INT len
)
1134 INT n
= GetLocaleInfoA( lcid
, LOCALE_SISO639LANGNAME
, rfc1766
, len
);
1137 rfc1766
[n
- 1] = '-';
1138 n
+= GetLocaleInfoA( lcid
, LOCALE_SISO3166CTRYNAME
, rfc1766
+ n
, len
- n
);
1139 LCMapStringA( LOCALE_USER_DEFAULT
, LCMAP_LOWERCASE
, rfc1766
, n
, rfc1766
, len
);
1145 static inline INT
lcid_to_rfc1766W( LCID lcid
, LPWSTR rfc1766
, INT len
)
1147 INT n
= GetLocaleInfoW( lcid
, LOCALE_SISO639LANGNAME
, rfc1766
, len
);
1151 rfc1766
[n
- 1] = '-';
1152 n
+= GetLocaleInfoW( lcid
, LOCALE_SISO3166CTRYNAME
, rfc1766
+ n
, len
- n
);
1154 rfc1766
[n
- 1] = '\0';
1155 LCMapStringW( LOCALE_USER_DEFAULT
, LCMAP_LOWERCASE
, rfc1766
, n
, rfc1766
, len
);
1161 HRESULT WINAPI
LcidToRfc1766A(
1166 TRACE("%04x %p %u\n", lcid
, pszRfc1766
, nChar
);
1168 if (lcid_to_rfc1766A( lcid
, pszRfc1766
, nChar
))
1174 HRESULT WINAPI
LcidToRfc1766W(
1179 TRACE("%04x %p %u\n", lcid
, pszRfc1766
, nChar
);
1181 if (lcid_to_rfc1766W( lcid
, pszRfc1766
, nChar
))
1187 static HRESULT
lcid_from_rfc1766(IEnumRfc1766
*iface
, LCID
*lcid
, LPCWSTR rfc1766
)
1192 while (IEnumRfc1766_Next(iface
, 1, &info
, &num
) == S_OK
)
1194 if (!strcmpW(info
.wszRfc1766
, rfc1766
))
1199 if (strlenW(rfc1766
) == 2 && !memcmp(info
.wszRfc1766
, rfc1766
, 2 * sizeof(WCHAR
)))
1201 *lcid
= PRIMARYLANGID(info
.lcid
);
1209 HRESULT WINAPI
Rfc1766ToLcidW(LCID
*pLocale
, LPCWSTR pszRfc1766
)
1211 IEnumRfc1766
*enumrfc1766
;
1214 TRACE("(%p, %s)\n", pLocale
, debugstr_w(pszRfc1766
));
1216 if (!pLocale
|| !pszRfc1766
)
1217 return E_INVALIDARG
;
1221 hr
= EnumRfc1766_create(0, &enumrfc1766
);
1225 hr
= lcid_from_rfc1766(enumrfc1766
, pLocale
, pszRfc1766
);
1226 IEnumRfc1766_Release(enumrfc1766
);
1231 HRESULT WINAPI
Rfc1766ToLcidA(LCID
*lcid
, LPCSTR rfc1766A
)
1233 WCHAR rfc1766W
[MAX_RFC1766_NAME
+ 1];
1235 MultiByteToWideChar(CP_ACP
, 0, rfc1766A
, -1, rfc1766W
, MAX_RFC1766_NAME
);
1236 rfc1766W
[MAX_RFC1766_NAME
] = 0;
1238 return Rfc1766ToLcidW(lcid
, rfc1766W
);
1241 /******************************************************************************
1242 * MLANG ClassFactory
1245 IClassFactory ITF_IClassFactory
;
1248 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
1249 } IClassFactoryImpl
;
1251 struct object_creation_info
1255 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
1258 static const struct object_creation_info object_creation
[] =
1260 { &CLSID_CMultiLanguage
, "CLSID_CMultiLanguage", MultiLanguage_create
},
1263 static HRESULT WINAPI
1264 MLANGCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
)
1266 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
1268 TRACE("%s\n", debugstr_guid(riid
) );
1270 if (IsEqualGUID(riid
, &IID_IUnknown
)
1271 || IsEqualGUID(riid
, &IID_IClassFactory
))
1273 IClassFactory_AddRef(iface
);
1278 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
1279 return E_NOINTERFACE
;
1282 static ULONG WINAPI
MLANGCF_AddRef(LPCLASSFACTORY iface
)
1284 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
1285 return InterlockedIncrement(&This
->ref
);
1288 static ULONG WINAPI
MLANGCF_Release(LPCLASSFACTORY iface
)
1290 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
1292 ULONG ref
= InterlockedDecrement(&This
->ref
);
1296 TRACE("Destroying %p\n", This
);
1297 HeapFree(GetProcessHeap(), 0, This
);
1303 static HRESULT WINAPI
MLANGCF_CreateInstance(LPCLASSFACTORY iface
, LPUNKNOWN pOuter
,
1304 REFIID riid
, LPVOID
*ppobj
)
1306 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
1310 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
1313 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
1314 if (SUCCEEDED(hres
)) {
1315 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
1316 IUnknown_Release(punk
);
1318 TRACE("returning (%p) -> %x\n", *ppobj
, hres
);
1322 static HRESULT WINAPI
MLANGCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
)
1332 static const IClassFactoryVtbl MLANGCF_Vtbl
=
1334 MLANGCF_QueryInterface
,
1337 MLANGCF_CreateInstance
,
1341 /******************************************************************
1342 * DllGetClassObject (MLANG.@)
1344 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
1347 IClassFactoryImpl
*factory
;
1349 TRACE("%s %s %p\n",debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
1351 if ( !IsEqualGUID( &IID_IClassFactory
, iid
)
1352 && ! IsEqualGUID( &IID_IUnknown
, iid
) )
1353 return E_NOINTERFACE
;
1355 for (i
=0; i
< sizeof(object_creation
)/sizeof(object_creation
[0]); i
++)
1357 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
1361 if (i
== sizeof(object_creation
)/sizeof(object_creation
[0]))
1363 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
1364 return CLASS_E_CLASSNOTAVAILABLE
;
1367 TRACE("Creating a class factory for %s\n",object_creation
[i
].szClassName
);
1369 factory
= HeapAlloc(GetProcessHeap(), 0, sizeof(*factory
));
1370 if (factory
== NULL
) return E_OUTOFMEMORY
;
1372 factory
->ITF_IClassFactory
.lpVtbl
= &MLANGCF_Vtbl
;
1375 factory
->pfnCreateInstance
= object_creation
[i
].pfnCreateInstance
;
1377 *ppv
= &(factory
->ITF_IClassFactory
);
1379 TRACE("(%p) <- %p\n", ppv
, &(factory
->ITF_IClassFactory
) );
1385 /******************************************************************************/
1387 typedef struct tagMLang_impl
1389 const IMLangFontLinkVtbl
*vtbl_IMLangFontLink
;
1390 const IMultiLanguageVtbl
*vtbl_IMultiLanguage
;
1391 const IMultiLanguage3Vtbl
*vtbl_IMultiLanguage3
;
1392 const IMLangFontLink2Vtbl
*vtbl_IMLangFontLink2
;
1393 const IMLangLineBreakConsoleVtbl
*vtbl_IMLangLineBreakConsole
;
1395 DWORD total_cp
, total_scripts
;
1398 static ULONG WINAPI
MLang_AddRef( MLang_impl
* This
)
1400 return InterlockedIncrement(&This
->ref
);
1403 static ULONG WINAPI
MLang_Release( MLang_impl
* This
)
1405 ULONG ref
= InterlockedDecrement(&This
->ref
);
1407 TRACE("%p ref = %d\n", This
, ref
);
1410 TRACE("Destroying %p\n", This
);
1411 HeapFree(GetProcessHeap(), 0, This
);
1418 static HRESULT WINAPI
MLang_QueryInterface(
1423 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
1425 if (IsEqualGUID(riid
, &IID_IUnknown
)
1426 || IsEqualGUID(riid
, &IID_IMLangCodePages
)
1427 || IsEqualGUID(riid
, &IID_IMLangFontLink
))
1430 TRACE("Returning IID_IMLangFontLink %p ref = %d\n", This
, This
->ref
);
1431 *ppvObject
= &(This
->vtbl_IMLangFontLink
);
1435 if (IsEqualGUID(riid
, &IID_IMLangFontLink2
))
1438 TRACE("Returning IID_IMLangFontLink2 %p ref = %d\n", This
, This
->ref
);
1439 *ppvObject
= &(This
->vtbl_IMLangFontLink2
);
1443 if (IsEqualGUID(riid
, &IID_IMultiLanguage
) )
1446 TRACE("Returning IID_IMultiLanguage %p ref = %d\n", This
, This
->ref
);
1447 *ppvObject
= &(This
->vtbl_IMultiLanguage
);
1451 if (IsEqualGUID(riid
, &IID_IMultiLanguage2
) )
1454 *ppvObject
= &(This
->vtbl_IMultiLanguage3
);
1455 TRACE("Returning IID_IMultiLanguage2 %p ref = %d\n", This
, This
->ref
);
1459 if (IsEqualGUID(riid
, &IID_IMultiLanguage3
) )
1462 *ppvObject
= &(This
->vtbl_IMultiLanguage3
);
1463 TRACE("Returning IID_IMultiLanguage3 %p ref = %d\n", This
, This
->ref
);
1467 if (IsEqualGUID(riid
, &IID_IMLangLineBreakConsole
))
1470 TRACE("Returning IID_IMLangLineBreakConsole %p ref = %d\n", This
, This
->ref
);
1471 *ppvObject
= &(This
->vtbl_IMLangLineBreakConsole
);
1476 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1477 return E_NOINTERFACE
;
1480 /******************************************************************************/
1482 typedef struct tagEnumCodePage_impl
1484 const IEnumCodePageVtbl
*vtbl_IEnumCodePage
;
1488 } EnumCodePage_impl
;
1490 static HRESULT WINAPI
fnIEnumCodePage_QueryInterface(
1491 IEnumCodePage
* iface
,
1495 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1497 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
1499 if (IsEqualGUID(riid
, &IID_IUnknown
)
1500 || IsEqualGUID(riid
, &IID_IEnumCodePage
))
1502 IEnumCodePage_AddRef(iface
);
1503 TRACE("Returning IID_IEnumCodePage %p ref = %d\n", This
, This
->ref
);
1504 *ppvObject
= &(This
->vtbl_IEnumCodePage
);
1508 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1509 return E_NOINTERFACE
;
1512 static ULONG WINAPI
fnIEnumCodePage_AddRef(
1513 IEnumCodePage
* iface
)
1515 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1516 return InterlockedIncrement(&This
->ref
);
1519 static ULONG WINAPI
fnIEnumCodePage_Release(
1520 IEnumCodePage
* iface
)
1522 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1523 ULONG ref
= InterlockedDecrement(&This
->ref
);
1525 TRACE("%p ref = %d\n", This
, ref
);
1528 TRACE("Destroying %p\n", This
);
1529 HeapFree(GetProcessHeap(), 0, This
->cpinfo
);
1530 HeapFree(GetProcessHeap(), 0, This
);
1536 static HRESULT WINAPI
fnIEnumCodePage_Clone(
1537 IEnumCodePage
* iface
,
1538 IEnumCodePage
** ppEnum
)
1540 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1541 FIXME("%p %p\n", This
, ppEnum
);
1545 static HRESULT WINAPI
fnIEnumCodePage_Next(
1546 IEnumCodePage
* iface
,
1549 ULONG
* pceltFetched
)
1553 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1554 TRACE("%p %u %p %p\n", This
, celt
, rgelt
, pceltFetched
);
1556 if (!pceltFetched
) return S_FALSE
;
1559 if (!rgelt
) return S_FALSE
;
1561 if (This
->pos
+ celt
> This
->total
)
1562 celt
= This
->total
- This
->pos
;
1564 if (!celt
) return S_FALSE
;
1566 memcpy(rgelt
, This
->cpinfo
+ This
->pos
, celt
* sizeof(MIMECPINFO
));
1567 *pceltFetched
= celt
;
1570 for (i
= 0; i
< celt
; i
++)
1572 TRACE("#%u: %08x %u %u %s %s %s %s %s %s %d\n",
1573 i
, rgelt
[i
].dwFlags
, rgelt
[i
].uiCodePage
,
1574 rgelt
[i
].uiFamilyCodePage
,
1575 wine_dbgstr_w(rgelt
[i
].wszDescription
),
1576 wine_dbgstr_w(rgelt
[i
].wszWebCharset
),
1577 wine_dbgstr_w(rgelt
[i
].wszHeaderCharset
),
1578 wine_dbgstr_w(rgelt
[i
].wszBodyCharset
),
1579 wine_dbgstr_w(rgelt
[i
].wszFixedWidthFont
),
1580 wine_dbgstr_w(rgelt
[i
].wszProportionalFont
),
1581 rgelt
[i
].bGDICharset
);
1586 static HRESULT WINAPI
fnIEnumCodePage_Reset(
1587 IEnumCodePage
* iface
)
1589 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1590 TRACE("%p\n", This
);
1596 static HRESULT WINAPI
fnIEnumCodePage_Skip(
1597 IEnumCodePage
* iface
,
1600 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1601 TRACE("%p %u\n", This
, celt
);
1603 if (celt
>= This
->total
) return S_FALSE
;
1609 static const IEnumCodePageVtbl IEnumCodePage_vtbl
=
1611 fnIEnumCodePage_QueryInterface
,
1612 fnIEnumCodePage_AddRef
,
1613 fnIEnumCodePage_Release
,
1614 fnIEnumCodePage_Clone
,
1615 fnIEnumCodePage_Next
,
1616 fnIEnumCodePage_Reset
,
1617 fnIEnumCodePage_Skip
1620 static HRESULT
EnumCodePage_create( MLang_impl
* mlang
, DWORD grfFlags
,
1621 LANGID LangId
, IEnumCodePage
** ppEnumCodePage
)
1623 EnumCodePage_impl
*ecp
;
1627 TRACE("%p, %08x, %04x, %p\n", mlang
, grfFlags
, LangId
, ppEnumCodePage
);
1629 if (!grfFlags
) /* enumerate internal data base of encodings */
1630 grfFlags
= MIMECONTF_MIME_LATEST
;
1632 ecp
= HeapAlloc( GetProcessHeap(), 0, sizeof (EnumCodePage_impl
) );
1633 ecp
->vtbl_IEnumCodePage
= &IEnumCodePage_vtbl
;
1637 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
1639 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
1641 if (mlang_data
[i
].mime_cp_info
[n
].flags
& grfFlags
)
1646 ecp
->cpinfo
= HeapAlloc(GetProcessHeap(), 0,
1647 sizeof(MIMECPINFO
) * ecp
->total
);
1648 cpinfo
= ecp
->cpinfo
;
1650 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
1652 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
1654 if (mlang_data
[i
].mime_cp_info
[n
].flags
& grfFlags
)
1655 fill_cp_info(&mlang_data
[i
], n
, cpinfo
++);
1659 TRACE("enumerated %d codepages with flags %08x\n", ecp
->total
, grfFlags
);
1661 *ppEnumCodePage
= (IEnumCodePage
*) ecp
;
1666 /******************************************************************************/
1668 typedef struct tagEnumScript_impl
1670 const IEnumScriptVtbl
*vtbl_IEnumScript
;
1672 SCRIPTINFO
*script_info
;
1676 static HRESULT WINAPI
fnIEnumScript_QueryInterface(
1681 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1683 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
1685 if (IsEqualGUID(riid
, &IID_IUnknown
)
1686 || IsEqualGUID(riid
, &IID_IEnumScript
))
1688 IEnumScript_AddRef(iface
);
1689 TRACE("Returning IID_IEnumScript %p ref = %d\n", This
, This
->ref
);
1690 *ppvObject
= &(This
->vtbl_IEnumScript
);
1694 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1695 return E_NOINTERFACE
;
1698 static ULONG WINAPI
fnIEnumScript_AddRef(
1701 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1702 return InterlockedIncrement(&This
->ref
);
1705 static ULONG WINAPI
fnIEnumScript_Release(
1708 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1709 ULONG ref
= InterlockedDecrement(&This
->ref
);
1711 TRACE("%p ref = %d\n", This
, ref
);
1714 TRACE("Destroying %p\n", This
);
1715 HeapFree(GetProcessHeap(), 0, This
->script_info
);
1716 HeapFree(GetProcessHeap(), 0, This
);
1722 static HRESULT WINAPI
fnIEnumScript_Clone(
1724 IEnumScript
** ppEnum
)
1726 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1727 FIXME("%p %p: stub!\n", This
, ppEnum
);
1731 static HRESULT WINAPI
fnIEnumScript_Next(
1735 ULONG
* pceltFetched
)
1737 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1738 TRACE("%p %u %p %p\n", This
, celt
, rgelt
, pceltFetched
);
1740 if (!pceltFetched
|| !rgelt
) return E_FAIL
;
1744 if (This
->pos
+ celt
> This
->total
)
1745 celt
= This
->total
- This
->pos
;
1747 if (!celt
) return S_FALSE
;
1749 memcpy(rgelt
, This
->script_info
+ This
->pos
, celt
* sizeof(SCRIPTINFO
));
1750 *pceltFetched
= celt
;
1756 static HRESULT WINAPI
fnIEnumScript_Reset(
1759 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1760 TRACE("%p\n", This
);
1766 static HRESULT WINAPI
fnIEnumScript_Skip(
1770 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1771 TRACE("%p %u\n", This
, celt
);
1773 if (celt
>= This
->total
) return S_FALSE
;
1779 static const IEnumScriptVtbl IEnumScript_vtbl
=
1781 fnIEnumScript_QueryInterface
,
1782 fnIEnumScript_AddRef
,
1783 fnIEnumScript_Release
,
1784 fnIEnumScript_Clone
,
1786 fnIEnumScript_Reset
,
1790 static HRESULT
EnumScript_create( MLang_impl
* mlang
, DWORD dwFlags
,
1791 LANGID LangId
, IEnumScript
** ppEnumScript
)
1793 EnumScript_impl
*es
;
1796 TRACE("%p, %08x, %04x, %p: stub!\n", mlang
, dwFlags
, LangId
, ppEnumScript
);
1798 if (!dwFlags
) /* enumerate all available scripts */
1799 dwFlags
= SCRIPTCONTF_SCRIPT_USER
| SCRIPTCONTF_SCRIPT_HIDE
| SCRIPTCONTF_SCRIPT_SYSTEM
;
1801 es
= HeapAlloc( GetProcessHeap(), 0, sizeof (EnumScript_impl
) );
1802 es
->vtbl_IEnumScript
= &IEnumScript_vtbl
;
1805 /* do not enumerate unicode flavours */
1806 es
->total
= sizeof(mlang_data
)/sizeof(mlang_data
[0]) - 1;
1807 es
->script_info
= HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPTINFO
) * es
->total
);
1809 for (i
= 0; i
< es
->total
; i
++)
1811 es
->script_info
[i
].ScriptId
= i
;
1812 es
->script_info
[i
].uiCodePage
= mlang_data
[i
].family_codepage
;
1813 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].description
, -1,
1814 es
->script_info
[i
].wszDescription
, MAX_SCRIPT_NAME
);
1815 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].fixed_font
, -1,
1816 es
->script_info
[i
].wszFixedWidthFont
, MAX_MIMEFACE_NAME
);
1817 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].proportional_font
, -1,
1818 es
->script_info
[i
].wszProportionalFont
, MAX_MIMEFACE_NAME
);
1821 TRACE("enumerated %d scripts with flags %08x\n", es
->total
, dwFlags
);
1823 *ppEnumScript
= (IEnumScript
*)es
;
1828 /******************************************************************************/
1830 static HRESULT WINAPI
fnIMLangFontLink_QueryInterface(
1831 IMLangFontLink
* iface
,
1835 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1836 return MLang_QueryInterface( This
, riid
, ppvObject
);
1839 static ULONG WINAPI
fnIMLangFontLink_AddRef(
1840 IMLangFontLink
* iface
)
1842 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1843 return MLang_AddRef( This
);
1846 static ULONG WINAPI
fnIMLangFontLink_Release(
1847 IMLangFontLink
* iface
)
1849 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1850 return MLang_Release( This
);
1853 static HRESULT WINAPI
fnIMLangFontLink_GetCharCodePages(
1854 IMLangFontLink
* iface
,
1856 DWORD
* pdwCodePages
)
1862 static HRESULT WINAPI
fnIMLangFontLink_GetStrCodePages(
1863 IMLangFontLink
* iface
,
1864 const WCHAR
* pszSrc
,
1866 DWORD dwPriorityCodePages
,
1867 DWORD
* pdwCodePages
,
1868 long* pcchCodePages
)
1870 FIXME("(pszSrc=%s, cchSrc=%ld, dwPriorityCodePages=%d) stub\n", debugstr_w(pszSrc
), cchSrc
, dwPriorityCodePages
);
1876 static HRESULT WINAPI
fnIMLangFontLink_CodePageToCodePages(
1877 IMLangFontLink
* iface
,
1879 DWORD
* pdwCodePages
)
1881 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1885 TRACE("(%p) Seeking %u\n",This
, uCodePage
);
1886 memset(&cs
, 0, sizeof(cs
));
1888 rc
= TranslateCharsetInfo((DWORD
*)uCodePage
, &cs
, TCI_SRCCODEPAGE
);
1892 *pdwCodePages
= cs
.fs
.fsCsb
[0];
1893 TRACE("resulting CodePages 0x%x\n",*pdwCodePages
);
1896 TRACE("CodePage Not Found\n");
1901 static HRESULT WINAPI
fnIMLangFontLink_CodePagesToCodePage(
1902 IMLangFontLink
* iface
,
1904 UINT uDefaultCodePage
,
1907 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1908 DWORD mask
= 0x00000000;
1913 TRACE("(%p) scanning 0x%x default page %u\n",This
, dwCodePages
,
1916 *puCodePage
= 0x00000000;
1918 rc
= TranslateCharsetInfo((DWORD
*)uDefaultCodePage
, &cs
, TCI_SRCCODEPAGE
);
1920 if (rc
&& (dwCodePages
& cs
.fs
.fsCsb
[0]))
1922 TRACE("Found Default Codepage\n");
1923 *puCodePage
= uDefaultCodePage
;
1928 for (i
= 0; i
< 32; i
++)
1932 if (dwCodePages
& mask
)
1937 rc
= TranslateCharsetInfo((DWORD
*)Csb
, &cs
, TCI_SRCFONTSIG
);
1941 TRACE("Falling back to least significant found CodePage %u\n",
1943 *puCodePage
= cs
.ciACP
;
1948 TRACE("no codepage found\n");
1952 static HRESULT WINAPI
fnIMLangFontLink_GetFontCodePages(
1953 IMLangFontLink
* iface
,
1956 DWORD
* pdwCodePages
)
1959 FONTSIGNATURE fontsig
;
1960 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1962 TRACE("(%p)\n",This
);
1964 old_font
= SelectObject(hDC
,hFont
);
1965 GetTextCharsetInfo(hDC
,&fontsig
, 0);
1966 SelectObject(hDC
,old_font
);
1968 *pdwCodePages
= fontsig
.fsCsb
[0];
1969 TRACE("CodePages is 0x%x\n",fontsig
.fsCsb
[0]);
1974 static HRESULT WINAPI
fnIMLangFontLink_MapFont(
1975 IMLangFontLink
* iface
,
1985 static HRESULT WINAPI
fnIMLangFontLink_ReleaseFont(
1986 IMLangFontLink
* iface
,
1993 static HRESULT WINAPI
fnIMLangFontLink_ResetFontMapping(
1994 IMLangFontLink
* iface
)
2001 static const IMLangFontLinkVtbl IMLangFontLink_vtbl
=
2003 fnIMLangFontLink_QueryInterface
,
2004 fnIMLangFontLink_AddRef
,
2005 fnIMLangFontLink_Release
,
2006 fnIMLangFontLink_GetCharCodePages
,
2007 fnIMLangFontLink_GetStrCodePages
,
2008 fnIMLangFontLink_CodePageToCodePages
,
2009 fnIMLangFontLink_CodePagesToCodePage
,
2010 fnIMLangFontLink_GetFontCodePages
,
2011 fnIMLangFontLink_MapFont
,
2012 fnIMLangFontLink_ReleaseFont
,
2013 fnIMLangFontLink_ResetFontMapping
,
2016 /******************************************************************************/
2018 static HRESULT WINAPI
fnIMultiLanguage_QueryInterface(
2019 IMultiLanguage
* iface
,
2023 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2024 return MLang_QueryInterface( This
, riid
, ppvObject
);
2027 static ULONG WINAPI
fnIMultiLanguage_AddRef( IMultiLanguage
* iface
)
2029 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2030 return IMLangFontLink_AddRef( ((IMLangFontLink
*)This
) );
2033 static ULONG WINAPI
fnIMultiLanguage_Release( IMultiLanguage
* iface
)
2035 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2036 return IMLangFontLink_Release( ((IMLangFontLink
*)This
) );
2039 static HRESULT WINAPI
fnIMultiLanguage_GetNumberOfCodePageInfo(
2040 IMultiLanguage
* iface
,
2047 static HRESULT WINAPI
fnIMultiLanguage_GetCodePageInfo(
2048 IMultiLanguage
* iface
,
2050 PMIMECPINFO pCodePageInfo
)
2054 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2055 TRACE("%p, %u, %p\n", This
, uiCodePage
, pCodePageInfo
);
2057 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2059 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2061 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
2063 fill_cp_info(&mlang_data
[i
], n
, pCodePageInfo
);
2072 static HRESULT WINAPI
fnIMultiLanguage_GetFamilyCodePage(
2073 IMultiLanguage
* iface
,
2075 UINT
* puiFamilyCodePage
)
2077 return GetFamilyCodePage(uiCodePage
, puiFamilyCodePage
);
2080 static HRESULT WINAPI
fnIMultiLanguage_EnumCodePages(
2081 IMultiLanguage
* iface
,
2083 IEnumCodePage
** ppEnumCodePage
)
2085 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2086 TRACE("%p %08x %p\n", This
, grfFlags
, ppEnumCodePage
);
2088 return EnumCodePage_create( This
, grfFlags
, 0, ppEnumCodePage
);
2091 static HRESULT WINAPI
fnIMultiLanguage_GetCharsetInfo(
2092 IMultiLanguage
* iface
,
2094 PMIMECSETINFO pCharsetInfo
)
2100 static HRESULT WINAPI
fnIMultiLanguage_IsConvertible(
2101 IMultiLanguage
* iface
,
2102 DWORD dwSrcEncoding
,
2103 DWORD dwDstEncoding
)
2105 return IsConvertINetStringAvailable(dwSrcEncoding
, dwDstEncoding
);
2108 static HRESULT WINAPI
fnIMultiLanguage_ConvertString(
2109 IMultiLanguage
* iface
,
2111 DWORD dwSrcEncoding
,
2112 DWORD dwDstEncoding
,
2118 return ConvertINetString(pdwMode
, dwSrcEncoding
, dwDstEncoding
,
2119 (LPCSTR
)pSrcStr
, (LPINT
)pcSrcSize
, (LPSTR
)pDstStr
, (LPINT
)pcDstSize
);
2122 static HRESULT WINAPI
fnIMultiLanguage_ConvertStringToUnicode(
2123 IMultiLanguage
* iface
,
2131 return ConvertINetMultiByteToUnicode(pdwMode
, dwEncoding
,
2132 (LPCSTR
)pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2135 static HRESULT WINAPI
fnIMultiLanguage_ConvertStringFromUnicode(
2136 IMultiLanguage
* iface
,
2144 return ConvertINetUnicodeToMultiByte(pdwMode
, dwEncoding
,
2145 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2148 static HRESULT WINAPI
fnIMultiLanguage_ConvertStringReset(
2149 IMultiLanguage
* iface
)
2155 static HRESULT WINAPI
fnIMultiLanguage_GetRfc1766FromLcid(
2156 IMultiLanguage
* iface
,
2160 WCHAR buf
[MAX_RFC1766_NAME
];
2162 TRACE("%p %04x %p\n", iface
, lcid
, pbstrRfc1766
);
2164 if (lcid_to_rfc1766W( lcid
, buf
, MAX_RFC1766_NAME
))
2166 *pbstrRfc1766
= SysAllocString( buf
);
2172 static HRESULT WINAPI
fnIMultiLanguage_GetLcidFromRfc1766(
2173 IMultiLanguage
* iface
,
2178 IEnumRfc1766
*rfc1766
;
2180 TRACE("%p %p %s\n", iface
, pLocale
, debugstr_w(bstrRfc1766
));
2182 if (!pLocale
|| !bstrRfc1766
)
2183 return E_INVALIDARG
;
2185 hr
= IMultiLanguage_EnumRfc1766(iface
, &rfc1766
);
2189 hr
= lcid_from_rfc1766(rfc1766
, pLocale
, bstrRfc1766
);
2191 IEnumRfc1766_Release(rfc1766
);
2195 /******************************************************************************/
2197 typedef struct tagEnumRfc1766_impl
2199 const IEnumRfc1766Vtbl
*vtbl_IEnumRfc1766
;
2205 static HRESULT WINAPI
fnIEnumRfc1766_QueryInterface(
2206 IEnumRfc1766
*iface
,
2210 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
2212 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
2214 if (IsEqualGUID(riid
, &IID_IUnknown
)
2215 || IsEqualGUID(riid
, &IID_IEnumRfc1766
))
2217 IEnumRfc1766_AddRef(iface
);
2218 TRACE("Returning IID_IEnumRfc1766 %p ref = %d\n", This
, This
->ref
);
2219 *ppvObject
= &(This
->vtbl_IEnumRfc1766
);
2223 WARN("(%p) -> (%s,%p), not found\n",This
,debugstr_guid(riid
),ppvObject
);
2224 return E_NOINTERFACE
;
2227 static ULONG WINAPI
fnIEnumRfc1766_AddRef(
2228 IEnumRfc1766
*iface
)
2230 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
2231 return InterlockedIncrement(&This
->ref
);
2234 static ULONG WINAPI
fnIEnumRfc1766_Release(
2235 IEnumRfc1766
*iface
)
2237 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
2238 ULONG ref
= InterlockedDecrement(&This
->ref
);
2240 TRACE("%p ref = %d\n", This
, ref
);
2243 TRACE("Destroying %p\n", This
);
2244 HeapFree(GetProcessHeap(), 0, This
->info
);
2245 HeapFree(GetProcessHeap(), 0, This
);
2250 static HRESULT WINAPI
fnIEnumRfc1766_Clone(
2251 IEnumRfc1766
*iface
,
2252 IEnumRfc1766
**ppEnum
)
2254 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
2255 FIXME("%p %p\n", This
, ppEnum
);
2259 static HRESULT WINAPI
fnIEnumRfc1766_Next(
2260 IEnumRfc1766
*iface
,
2263 ULONG
*pceltFetched
)
2267 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
2268 TRACE("%p %u %p %p\n", This
, celt
, rgelt
, pceltFetched
);
2270 if (!pceltFetched
) return S_FALSE
;
2273 if (!rgelt
) return S_FALSE
;
2275 if (This
->pos
+ celt
> This
->total
)
2276 celt
= This
->total
- This
->pos
;
2278 if (!celt
) return S_FALSE
;
2280 memcpy(rgelt
, This
->info
+ This
->pos
, celt
* sizeof(RFC1766INFO
));
2281 *pceltFetched
= celt
;
2284 for (i
= 0; i
< celt
; i
++)
2286 TRACE("#%u: %08x %s %s\n",
2288 wine_dbgstr_w(rgelt
[i
].wszRfc1766
),
2289 wine_dbgstr_w(rgelt
[i
].wszLocaleName
));
2294 static HRESULT WINAPI
fnIEnumRfc1766_Reset(
2295 IEnumRfc1766
*iface
)
2297 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
2298 TRACE("%p\n", This
);
2304 static HRESULT WINAPI
fnIEnumRfc1766_Skip(
2305 IEnumRfc1766
*iface
,
2308 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
2309 TRACE("%p %u\n", This
, celt
);
2311 if (celt
>= This
->total
) return S_FALSE
;
2317 static const IEnumRfc1766Vtbl IEnumRfc1766_vtbl
=
2319 fnIEnumRfc1766_QueryInterface
,
2320 fnIEnumRfc1766_AddRef
,
2321 fnIEnumRfc1766_Release
,
2322 fnIEnumRfc1766_Clone
,
2323 fnIEnumRfc1766_Next
,
2324 fnIEnumRfc1766_Reset
,
2328 struct enum_locales_data
2331 DWORD total
, allocated
;
2334 static BOOL CALLBACK
enum_locales_proc(LPWSTR locale
)
2337 struct enum_locales_data
*data
= TlsGetValue(MLANG_tls_index
);
2340 TRACE("%s\n", debugstr_w(locale
));
2342 if (data
->total
>= data
->allocated
)
2344 data
->allocated
+= 32;
2345 data
->info
= HeapReAlloc(GetProcessHeap(), 0, data
->info
, data
->allocated
* sizeof(RFC1766INFO
));
2346 if (!data
->info
) return FALSE
;
2349 info
= &data
->info
[data
->total
];
2351 info
->lcid
= strtolW(locale
, &end
, 16);
2352 if (*end
) /* invalid number */
2355 info
->wszRfc1766
[0] = 0;
2356 lcid_to_rfc1766W( info
->lcid
, info
->wszRfc1766
, MAX_RFC1766_NAME
);
2358 info
->wszLocaleName
[0] = 0;
2359 GetLocaleInfoW(info
->lcid
, LOCALE_SLANGUAGE
, info
->wszLocaleName
, MAX_LOCALE_NAME
);
2360 TRACE("ISO639: %s SLANGUAGE: %s\n", wine_dbgstr_w(info
->wszRfc1766
), wine_dbgstr_w(info
->wszLocaleName
));
2367 static HRESULT
EnumRfc1766_create(LANGID LangId
, IEnumRfc1766
**ppEnum
)
2369 EnumRfc1766_impl
*rfc
;
2370 struct enum_locales_data data
;
2372 TRACE("%04x, %p\n", LangId
, ppEnum
);
2374 rfc
= HeapAlloc( GetProcessHeap(), 0, sizeof(EnumRfc1766_impl
) );
2375 rfc
->vtbl_IEnumRfc1766
= &IEnumRfc1766_vtbl
;
2381 data
.allocated
= 32;
2382 data
.info
= HeapAlloc(GetProcessHeap(), 0, data
.allocated
* sizeof(RFC1766INFO
));
2385 HeapFree(GetProcessHeap(), 0, rfc
);
2389 TlsSetValue(MLANG_tls_index
, &data
);
2390 EnumSystemLocalesW(enum_locales_proc
, 0/*LOCALE_SUPPORTED*/);
2391 TlsSetValue(MLANG_tls_index
, NULL
);
2393 TRACE("enumerated %d rfc1766 structures\n", data
.total
);
2397 HeapFree(GetProcessHeap(), 0, data
.info
);
2398 HeapFree(GetProcessHeap(), 0, rfc
);
2402 rfc
->info
= data
.info
;
2403 rfc
->total
= data
.total
;
2405 *ppEnum
= (IEnumRfc1766
*)rfc
;
2409 static HRESULT WINAPI
fnIMultiLanguage_EnumRfc1766(
2410 IMultiLanguage
*iface
,
2411 IEnumRfc1766
**ppEnumRfc1766
)
2413 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2414 TRACE("%p %p\n", This
, ppEnumRfc1766
);
2416 return EnumRfc1766_create(0, ppEnumRfc1766
);
2419 /******************************************************************************/
2421 static HRESULT WINAPI
fnIMultiLanguage_GetRfc1766Info(
2422 IMultiLanguage
* iface
,
2424 PRFC1766INFO pRfc1766Info
)
2430 static HRESULT WINAPI
fnIMultiLanguage_CreateConvertCharset(
2431 IMultiLanguage
* iface
,
2435 IMLangConvertCharset
** ppMLangConvertCharset
)
2441 static const IMultiLanguageVtbl IMultiLanguage_vtbl
=
2443 fnIMultiLanguage_QueryInterface
,
2444 fnIMultiLanguage_AddRef
,
2445 fnIMultiLanguage_Release
,
2446 fnIMultiLanguage_GetNumberOfCodePageInfo
,
2447 fnIMultiLanguage_GetCodePageInfo
,
2448 fnIMultiLanguage_GetFamilyCodePage
,
2449 fnIMultiLanguage_EnumCodePages
,
2450 fnIMultiLanguage_GetCharsetInfo
,
2451 fnIMultiLanguage_IsConvertible
,
2452 fnIMultiLanguage_ConvertString
,
2453 fnIMultiLanguage_ConvertStringToUnicode
,
2454 fnIMultiLanguage_ConvertStringFromUnicode
,
2455 fnIMultiLanguage_ConvertStringReset
,
2456 fnIMultiLanguage_GetRfc1766FromLcid
,
2457 fnIMultiLanguage_GetLcidFromRfc1766
,
2458 fnIMultiLanguage_EnumRfc1766
,
2459 fnIMultiLanguage_GetRfc1766Info
,
2460 fnIMultiLanguage_CreateConvertCharset
,
2464 /******************************************************************************/
2466 static HRESULT WINAPI
fnIMultiLanguage2_QueryInterface(
2467 IMultiLanguage3
* iface
,
2471 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2472 return MLang_QueryInterface( This
, riid
, ppvObject
);
2475 static ULONG WINAPI
fnIMultiLanguage2_AddRef( IMultiLanguage3
* iface
)
2477 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2478 return MLang_AddRef( This
);
2481 static ULONG WINAPI
fnIMultiLanguage2_Release( IMultiLanguage3
* iface
)
2483 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2484 return MLang_Release( This
);
2487 static HRESULT WINAPI
fnIMultiLanguage2_GetNumberOfCodePageInfo(
2488 IMultiLanguage3
* iface
,
2491 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2492 TRACE("%p, %p\n", This
, pcCodePage
);
2494 if (!pcCodePage
) return S_FALSE
;
2496 *pcCodePage
= This
->total_cp
;
2500 static void fill_cp_info(const struct mlang_data
*ml_data
, UINT index
, MIMECPINFO
*mime_cp_info
)
2504 if (TranslateCharsetInfo((DWORD
*)ml_data
->family_codepage
, &csi
, TCI_SRCCODEPAGE
))
2505 mime_cp_info
->bGDICharset
= csi
.ciCharset
;
2507 mime_cp_info
->bGDICharset
= DEFAULT_CHARSET
;
2509 mime_cp_info
->dwFlags
= ml_data
->mime_cp_info
[index
].flags
;
2510 mime_cp_info
->uiCodePage
= ml_data
->mime_cp_info
[index
].cp
;
2511 mime_cp_info
->uiFamilyCodePage
= ml_data
->family_codepage
;
2512 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].description
, -1,
2513 mime_cp_info
->wszDescription
, sizeof(mime_cp_info
->wszDescription
)/sizeof(WCHAR
));
2514 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].web_charset
, -1,
2515 mime_cp_info
->wszWebCharset
, sizeof(mime_cp_info
->wszWebCharset
)/sizeof(WCHAR
));
2516 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].header_charset
, -1,
2517 mime_cp_info
->wszHeaderCharset
, sizeof(mime_cp_info
->wszHeaderCharset
)/sizeof(WCHAR
));
2518 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].body_charset
, -1,
2519 mime_cp_info
->wszBodyCharset
, sizeof(mime_cp_info
->wszBodyCharset
)/sizeof(WCHAR
));
2521 MultiByteToWideChar(CP_ACP
, 0, ml_data
->fixed_font
, -1,
2522 mime_cp_info
->wszFixedWidthFont
, sizeof(mime_cp_info
->wszFixedWidthFont
)/sizeof(WCHAR
));
2523 MultiByteToWideChar(CP_ACP
, 0, ml_data
->proportional_font
, -1,
2524 mime_cp_info
->wszProportionalFont
, sizeof(mime_cp_info
->wszProportionalFont
)/sizeof(WCHAR
));
2526 TRACE("%08x %u %u %s %s %s %s %s %s %d\n",
2527 mime_cp_info
->dwFlags
, mime_cp_info
->uiCodePage
,
2528 mime_cp_info
->uiFamilyCodePage
,
2529 wine_dbgstr_w(mime_cp_info
->wszDescription
),
2530 wine_dbgstr_w(mime_cp_info
->wszWebCharset
),
2531 wine_dbgstr_w(mime_cp_info
->wszHeaderCharset
),
2532 wine_dbgstr_w(mime_cp_info
->wszBodyCharset
),
2533 wine_dbgstr_w(mime_cp_info
->wszFixedWidthFont
),
2534 wine_dbgstr_w(mime_cp_info
->wszProportionalFont
),
2535 mime_cp_info
->bGDICharset
);
2538 static HRESULT WINAPI
fnIMultiLanguage2_GetCodePageInfo(
2539 IMultiLanguage3
* iface
,
2542 PMIMECPINFO pCodePageInfo
)
2546 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2547 TRACE("%p, %u, %04x, %p\n", This
, uiCodePage
, LangId
, pCodePageInfo
);
2549 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2551 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2553 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
2555 fill_cp_info(&mlang_data
[i
], n
, pCodePageInfo
);
2564 static HRESULT WINAPI
fnIMultiLanguage2_GetFamilyCodePage(
2565 IMultiLanguage3
* iface
,
2567 UINT
* puiFamilyCodePage
)
2569 return GetFamilyCodePage(uiCodePage
, puiFamilyCodePage
);
2572 static HRESULT WINAPI
fnIMultiLanguage2_EnumCodePages(
2573 IMultiLanguage3
* iface
,
2576 IEnumCodePage
** ppEnumCodePage
)
2578 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2579 TRACE("%p %08x %04x %p\n", This
, grfFlags
, LangId
, ppEnumCodePage
);
2581 return EnumCodePage_create( This
, grfFlags
, LangId
, ppEnumCodePage
);
2584 static HRESULT WINAPI
fnIMultiLanguage2_GetCharsetInfo(
2585 IMultiLanguage3
* iface
,
2587 PMIMECSETINFO pCharsetInfo
)
2591 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2592 TRACE("%p %s %p\n", This
, debugstr_w(Charset
), pCharsetInfo
);
2594 if (!pCharsetInfo
) return E_FAIL
;
2596 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2598 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2600 WCHAR csetW
[MAX_MIMECSET_NAME
];
2602 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].mime_cp_info
[n
].web_charset
, -1, csetW
, MAX_MIMECSET_NAME
);
2603 if (!lstrcmpiW(Charset
, csetW
))
2605 pCharsetInfo
->uiCodePage
= mlang_data
[i
].family_codepage
;
2606 pCharsetInfo
->uiInternetEncoding
= mlang_data
[i
].mime_cp_info
[n
].cp
;
2607 strcpyW(pCharsetInfo
->wszCharset
, csetW
);
2614 * Since we do not support charsets like iso-2022-jp and do not have
2615 * them in our database as a primary (web_charset) encoding this loop
2616 * does an attempt to 'approximate' charset name by header_charset.
2618 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2620 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2622 WCHAR csetW
[MAX_MIMECSET_NAME
];
2624 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].mime_cp_info
[n
].header_charset
, -1, csetW
, MAX_MIMECSET_NAME
);
2625 if (!lstrcmpiW(Charset
, csetW
))
2627 pCharsetInfo
->uiCodePage
= mlang_data
[i
].family_codepage
;
2628 pCharsetInfo
->uiInternetEncoding
= mlang_data
[i
].mime_cp_info
[n
].cp
;
2629 strcpyW(pCharsetInfo
->wszCharset
, csetW
);
2638 static HRESULT WINAPI
fnIMultiLanguage2_IsConvertible(
2639 IMultiLanguage3
* iface
,
2640 DWORD dwSrcEncoding
,
2641 DWORD dwDstEncoding
)
2643 return IsConvertINetStringAvailable(dwSrcEncoding
, dwDstEncoding
);
2646 static HRESULT WINAPI
fnIMultiLanguage2_ConvertString(
2647 IMultiLanguage3
* iface
,
2649 DWORD dwSrcEncoding
,
2650 DWORD dwDstEncoding
,
2656 return ConvertINetString(pdwMode
, dwSrcEncoding
, dwDstEncoding
,
2657 (LPCSTR
)pSrcStr
, (LPINT
)pcSrcSize
, (LPSTR
)pDstStr
, (LPINT
)pcDstSize
);
2660 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringToUnicode(
2661 IMultiLanguage3
* iface
,
2669 return ConvertINetMultiByteToUnicode(pdwMode
, dwEncoding
,
2670 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2673 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringFromUnicode(
2674 IMultiLanguage3
* iface
,
2682 return ConvertINetUnicodeToMultiByte(pdwMode
, dwEncoding
,
2683 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2686 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringReset(
2687 IMultiLanguage3
* iface
)
2693 static HRESULT WINAPI
fnIMultiLanguage2_GetRfc1766FromLcid(
2694 IMultiLanguage3
* iface
,
2698 WCHAR buf
[MAX_RFC1766_NAME
];
2700 TRACE("%p %04x %p\n", iface
, lcid
, pbstrRfc1766
);
2702 if (lcid_to_rfc1766W( lcid
, buf
, MAX_RFC1766_NAME
))
2704 *pbstrRfc1766
= SysAllocString( buf
);
2710 static HRESULT WINAPI
fnIMultiLanguage2_GetLcidFromRfc1766(
2711 IMultiLanguage3
* iface
,
2716 IEnumRfc1766
*rfc1766
;
2718 TRACE("%p %p %s\n", iface
, pLocale
, debugstr_w(bstrRfc1766
));
2720 if (!pLocale
|| !bstrRfc1766
)
2721 return E_INVALIDARG
;
2723 hr
= IMultiLanguage2_EnumRfc1766(iface
, 0, &rfc1766
);
2727 hr
= lcid_from_rfc1766(rfc1766
, pLocale
, bstrRfc1766
);
2729 IEnumRfc1766_Release(rfc1766
);
2733 static HRESULT WINAPI
fnIMultiLanguage2_EnumRfc1766(
2734 IMultiLanguage3
* iface
,
2736 IEnumRfc1766
** ppEnumRfc1766
)
2738 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2739 TRACE("%p %p\n", This
, ppEnumRfc1766
);
2741 return EnumRfc1766_create(LangId
, ppEnumRfc1766
);
2744 static HRESULT WINAPI
fnIMultiLanguage2_GetRfc1766Info(
2745 IMultiLanguage3
* iface
,
2748 PRFC1766INFO pRfc1766Info
)
2754 static HRESULT WINAPI
fnIMultiLanguage2_CreateConvertCharset(
2755 IMultiLanguage3
* iface
,
2759 IMLangConvertCharset
** ppMLangConvertCharset
)
2765 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringInIStream(
2766 IMultiLanguage3
* iface
,
2770 DWORD dwSrcEncoding
,
2771 DWORD dwDstEncoding
,
2780 * TODO: handle dwFlag and lpFallBack
2782 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringToUnicodeEx(
2783 IMultiLanguage3
* iface
,
2794 return ConvertINetMultiByteToUnicode(pdwMode
, dwEncoding
,
2795 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2798 /*****************************************************************************
2799 * MultiLanguage2::ConvertStringToUnicodeEx
2801 * Translates the multibyte string from the specified code page to Unicode.
2804 * see ConvertStringToUnicode
2806 * lpFallBack if dwFlag contains MLCONVCHARF_USEDEFCHAR, lpFallBack string used
2807 * instead unconvertible characters.
2811 * S_FALSE The conversion is not supported.
2812 * E_FAIL Some error has occurred.
2814 * TODO: handle dwFlag and lpFallBack
2816 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringFromUnicodeEx(
2817 IMultiLanguage3
* This
,
2828 return ConvertINetUnicodeToMultiByte(pdwMode
, dwEncoding
,
2829 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2832 static HRESULT WINAPI
fnIMultiLanguage2_DetectCodepageInIStream(
2833 IMultiLanguage3
* iface
,
2835 DWORD dwPrefWinCodePage
,
2837 DetectEncodingInfo
* lpEncoding
,
2844 static HRESULT WINAPI
fnIMultiLanguage2_DetectInputCodepage(
2845 IMultiLanguage3
* iface
,
2847 DWORD dwPrefWinCodePage
,
2850 DetectEncodingInfo
* lpEncoding
,
2857 static HRESULT WINAPI
fnIMultiLanguage2_ValidateCodePage(
2858 IMultiLanguage3
* iface
,
2862 FIXME("%u, %p\n", uiCodePage
, hwnd
);
2866 static HRESULT WINAPI
fnIMultiLanguage2_GetCodePageDescription(
2867 IMultiLanguage3
* iface
,
2870 LPWSTR lpWideCharStr
,
2873 /* Find first instance */
2876 TRACE ("%u, %04x, %p, %d\n", uiCodePage
, lcid
, lpWideCharStr
, cchWideChar
);
2877 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2879 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2881 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
2883 MultiByteToWideChar(CP_ACP
, 0,
2884 mlang_data
[i
].mime_cp_info
[n
].description
,
2885 -1, lpWideCharStr
, cchWideChar
);
2894 static HRESULT WINAPI
fnIMultiLanguage2_IsCodePageInstallable(
2895 IMultiLanguage3
* iface
,
2898 FIXME("%u\n", uiCodePage
);
2902 static HRESULT WINAPI
fnIMultiLanguage2_SetMimeDBSource(
2903 IMultiLanguage3
* iface
,
2906 FIXME("0x%08x\n", dwSource
);
2910 static HRESULT WINAPI
fnIMultiLanguage2_GetNumberOfScripts(
2911 IMultiLanguage3
* iface
,
2914 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2915 TRACE("%p %p\n", This
, pnScripts
);
2917 if (!pnScripts
) return S_FALSE
;
2919 *pnScripts
= This
->total_scripts
;
2923 static HRESULT WINAPI
fnIMultiLanguage2_EnumScripts(
2924 IMultiLanguage3
* iface
,
2927 IEnumScript
** ppEnumScript
)
2929 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2930 TRACE("%p %08x %04x %p\n", This
, dwFlags
, LangId
, ppEnumScript
);
2932 return EnumScript_create( This
, dwFlags
, LangId
, ppEnumScript
);
2935 static HRESULT WINAPI
fnIMultiLanguage2_ValidateCodePageEx(
2936 IMultiLanguage3
* iface
,
2939 DWORD dwfIODControl
)
2941 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2942 FIXME("%p %u %p %08x: stub!\n", This
, uiCodePage
, hwnd
, dwfIODControl
);
2947 static HRESULT WINAPI
fnIMultiLanguage3_DetectOutboundCodePage(
2948 IMultiLanguage3
*iface
,
2950 LPCWSTR lpWideCharStr
,
2952 UINT
*puiPreferredCodePages
,
2953 UINT nPreferredCodePages
,
2954 UINT
*puiDetectedCodePages
,
2955 UINT
*pnDetectedCodePages
,
2956 WCHAR
*lpSpecialChar
)
2958 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2959 FIXME("(%p)->(%08x %s %u %p %u %p %p %p)\n", This
, dwFlags
, debugstr_w(lpWideCharStr
),
2960 cchWideChar
, puiPreferredCodePages
, nPreferredCodePages
, puiDetectedCodePages
,
2961 pnDetectedCodePages
, lpSpecialChar
);
2965 static HRESULT WINAPI
fnIMultiLanguage3_DetectOutboundCodePageInIStream(
2966 IMultiLanguage3
*iface
,
2969 UINT
*puiPreferredCodePages
,
2970 UINT nPreferredCodePages
,
2971 UINT
*puiDetectedCodePages
,
2972 UINT
*pnDetectedCodePages
,
2973 WCHAR
*lpSpecialChar
)
2975 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2976 FIXME("(%p)->(%08x %p %p %u %p %p %p)\n", This
, dwFlags
, pStrIn
,
2977 puiPreferredCodePages
, nPreferredCodePages
, puiDetectedCodePages
,
2978 pnDetectedCodePages
, lpSpecialChar
);
2982 static const IMultiLanguage3Vtbl IMultiLanguage3_vtbl
=
2984 fnIMultiLanguage2_QueryInterface
,
2985 fnIMultiLanguage2_AddRef
,
2986 fnIMultiLanguage2_Release
,
2987 fnIMultiLanguage2_GetNumberOfCodePageInfo
,
2988 fnIMultiLanguage2_GetCodePageInfo
,
2989 fnIMultiLanguage2_GetFamilyCodePage
,
2990 fnIMultiLanguage2_EnumCodePages
,
2991 fnIMultiLanguage2_GetCharsetInfo
,
2992 fnIMultiLanguage2_IsConvertible
,
2993 fnIMultiLanguage2_ConvertString
,
2994 fnIMultiLanguage2_ConvertStringToUnicode
,
2995 fnIMultiLanguage2_ConvertStringFromUnicode
,
2996 fnIMultiLanguage2_ConvertStringReset
,
2997 fnIMultiLanguage2_GetRfc1766FromLcid
,
2998 fnIMultiLanguage2_GetLcidFromRfc1766
,
2999 fnIMultiLanguage2_EnumRfc1766
,
3000 fnIMultiLanguage2_GetRfc1766Info
,
3001 fnIMultiLanguage2_CreateConvertCharset
,
3002 fnIMultiLanguage2_ConvertStringInIStream
,
3003 fnIMultiLanguage2_ConvertStringToUnicodeEx
,
3004 fnIMultiLanguage2_ConvertStringFromUnicodeEx
,
3005 fnIMultiLanguage2_DetectCodepageInIStream
,
3006 fnIMultiLanguage2_DetectInputCodepage
,
3007 fnIMultiLanguage2_ValidateCodePage
,
3008 fnIMultiLanguage2_GetCodePageDescription
,
3009 fnIMultiLanguage2_IsCodePageInstallable
,
3010 fnIMultiLanguage2_SetMimeDBSource
,
3011 fnIMultiLanguage2_GetNumberOfScripts
,
3012 fnIMultiLanguage2_EnumScripts
,
3013 fnIMultiLanguage2_ValidateCodePageEx
,
3014 fnIMultiLanguage3_DetectOutboundCodePage
,
3015 fnIMultiLanguage3_DetectOutboundCodePageInIStream
3018 /******************************************************************************/
3019 static HRESULT WINAPI
fnIMLangFontLink2_QueryInterface(
3020 IMLangFontLink2
* iface
,
3024 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink2
, iface
);
3025 return MLang_QueryInterface( This
, riid
, ppvObject
);
3028 static ULONG WINAPI
fnIMLangFontLink2_AddRef( IMLangFontLink2
* iface
)
3030 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink2
, iface
);
3031 return MLang_AddRef( This
);
3034 static ULONG WINAPI
fnIMLangFontLink2_Release( IMLangFontLink2
* iface
)
3036 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink2
, iface
);
3037 return MLang_Release( This
);
3040 static HRESULT WINAPI
fnIMLangFontLink2_GetCharCodePages( IMLangFontLink2
* This
,
3041 WCHAR chSrc
, DWORD
*pdwCodePages
)
3043 FIXME("(%p)->%s %p\n",This
, debugstr_wn(&chSrc
,1),pdwCodePages
);
3047 static HRESULT WINAPI
fnIMLangFontLink2_GetStrCodePages( IMLangFontLink2
* This
,
3048 const WCHAR
*pszSrc
, long cchSrc
, DWORD dwPriorityCodePages
,
3049 DWORD
*pdwCodePages
, long *pcchCodePages
)
3051 FIXME("(%p)->%s %li %x %p %p\n",This
, debugstr_wn(pszSrc
,cchSrc
),cchSrc
,dwPriorityCodePages
,pdwCodePages
,pcchCodePages
);
3055 static HRESULT WINAPI
fnIMLangFontLink2_CodePageToCodePages(IMLangFontLink2
* This
,
3057 DWORD
*pdwCodePages
)
3059 FIXME("(%p)->%i %p\n",This
, uCodePage
, pdwCodePages
);
3063 static HRESULT WINAPI
fnIMLangFontLink2_CodePagesToCodePage(IMLangFontLink2
* This
,
3064 DWORD dwCodePages
, UINT uDefaultCodePage
, UINT
*puCodePage
)
3066 FIXME("(%p)->%i %i %p\n",This
, dwCodePages
, uDefaultCodePage
, puCodePage
);
3070 static HRESULT WINAPI
fnIMLangFontLink2_GetFontCodePages(IMLangFontLink2
* This
,
3071 HDC hDC
, HFONT hFont
, DWORD
*pdwCodePages
)
3073 FIXME("(%p)->%p %p %p\n",This
, hDC
, hFont
, pdwCodePages
);
3077 static HRESULT WINAPI
fnIMLangFontLink2_ReleaseFont(IMLangFontLink2
* This
,
3080 FIXME("(%p)->%p\n",This
, hFont
);
3084 static HRESULT WINAPI
fnIMLangFontLink2_ResetFontMapping(IMLangFontLink2
* This
)
3086 FIXME("(%p)->\n",This
);
3090 static HRESULT WINAPI
fnIMLangFontLink2_MapFont(IMLangFontLink2
* This
,
3091 HDC hDC
, DWORD dwCodePages
, WCHAR chSrc
, HFONT
*pFont
)
3093 FIXME("(%p)->%p %i %s %p\n",This
, hDC
, dwCodePages
, debugstr_wn(&chSrc
,1), pFont
);
3097 static HRESULT WINAPI
fnIMLangFontLink2_GetFontUnicodeRanges(IMLangFontLink2
* This
,
3098 HDC hDC
, UINT
*puiRanges
, UNICODERANGE
*pUranges
)
3100 FIXME("(%p)->%p %p %p\n",This
, hDC
, puiRanges
, pUranges
);
3104 static HRESULT WINAPI
fnIMLangFontLink2_GetScriptFontInfo(IMLangFontLink2
* This
,
3105 SCRIPT_ID sid
, DWORD dwFlags
, UINT
*puiFonts
,
3106 SCRIPTFONTINFO
*pScriptFont
)
3108 FIXME("(%p)->%i %i %p %p\n",This
, sid
, dwFlags
, puiFonts
, pScriptFont
);
3112 static HRESULT WINAPI
fnIMLangFontLink2_CodePageToScriptID(IMLangFontLink2
* This
,
3113 UINT uiCodePage
, SCRIPT_ID
*pSid
)
3115 FIXME("(%p)->%i %p\n",This
, uiCodePage
, pSid
);
3119 static const IMLangFontLink2Vtbl IMLangFontLink2_vtbl
=
3121 fnIMLangFontLink2_QueryInterface
,
3122 fnIMLangFontLink2_AddRef
,
3123 fnIMLangFontLink2_Release
,
3124 fnIMLangFontLink2_GetCharCodePages
,
3125 fnIMLangFontLink2_GetStrCodePages
,
3126 fnIMLangFontLink2_CodePageToCodePages
,
3127 fnIMLangFontLink2_CodePagesToCodePage
,
3128 fnIMLangFontLink2_GetFontCodePages
,
3129 fnIMLangFontLink2_ReleaseFont
,
3130 fnIMLangFontLink2_ResetFontMapping
,
3131 fnIMLangFontLink2_MapFont
,
3132 fnIMLangFontLink2_GetFontUnicodeRanges
,
3133 fnIMLangFontLink2_GetScriptFontInfo
,
3134 fnIMLangFontLink2_CodePageToScriptID
3137 /******************************************************************************/
3139 static HRESULT WINAPI
fnIMLangLineBreakConsole_QueryInterface(
3140 IMLangLineBreakConsole
* iface
,
3144 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangLineBreakConsole
, iface
);
3145 return MLang_QueryInterface( This
, riid
, ppvObject
);
3148 static ULONG WINAPI
fnIMLangLineBreakConsole_AddRef(
3149 IMLangLineBreakConsole
* iface
)
3151 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangLineBreakConsole
, iface
);
3152 return MLang_AddRef( This
);
3155 static ULONG WINAPI
fnIMLangLineBreakConsole_Release(
3156 IMLangLineBreakConsole
* iface
)
3158 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangLineBreakConsole
, iface
);
3159 return MLang_Release( This
);
3162 static HRESULT WINAPI
fnIMLangLineBreakConsole_BreakLineML(
3163 IMLangLineBreakConsole
* iface
,
3164 IMLangString
* pSrcMLStr
,
3172 FIXME("(%p)->%p %li %li %li %li %p %p\n", iface
, pSrcMLStr
, lSrcPos
, lSrcLen
, cMinColumns
, cMaxColumns
, plLineLen
, plSkipLen
);
3176 static HRESULT WINAPI
fnIMLangLineBreakConsole_BreakLineW(
3177 IMLangLineBreakConsole
* iface
,
3179 const WCHAR
* pszSrc
,
3185 FIXME("(%p)->%i %s %li %li %p %p\n", iface
, locale
, debugstr_wn(pszSrc
,cchSrc
), cchSrc
, cMaxColumns
, pcchLine
, pcchSkip
);
3192 static HRESULT WINAPI
fnIMLangLineBreakConsole_BreakLineA(
3193 IMLangLineBreakConsole
* iface
,
3202 FIXME("(%p)->%i %i %s %li %li %p %p\n", iface
, locale
, uCodePage
, debugstr_an(pszSrc
,cchSrc
), cchSrc
, cMaxColumns
, pcchLine
, pcchSkip
);
3209 static const IMLangLineBreakConsoleVtbl IMLangLineBreakConsole_vtbl
=
3211 fnIMLangLineBreakConsole_QueryInterface
,
3212 fnIMLangLineBreakConsole_AddRef
,
3213 fnIMLangLineBreakConsole_Release
,
3214 fnIMLangLineBreakConsole_BreakLineML
,
3215 fnIMLangLineBreakConsole_BreakLineW
,
3216 fnIMLangLineBreakConsole_BreakLineA
3219 static HRESULT
MultiLanguage_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
3224 TRACE("Creating MultiLanguage object\n");
3227 return CLASS_E_NOAGGREGATION
;
3229 mlang
= HeapAlloc( GetProcessHeap(), 0, sizeof (MLang_impl
) );
3230 mlang
->vtbl_IMLangFontLink
= &IMLangFontLink_vtbl
;
3231 mlang
->vtbl_IMultiLanguage
= &IMultiLanguage_vtbl
;
3232 mlang
->vtbl_IMultiLanguage3
= &IMultiLanguage3_vtbl
;
3233 mlang
->vtbl_IMLangFontLink2
= &IMLangFontLink2_vtbl
;
3234 mlang
->vtbl_IMLangLineBreakConsole
= &IMLangLineBreakConsole_vtbl
;
3236 mlang
->total_cp
= 0;
3237 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
3238 mlang
->total_cp
+= mlang_data
[i
].number_of_cp
;
3240 /* do not enumerate unicode flavours */
3241 mlang
->total_scripts
= sizeof(mlang_data
)/sizeof(mlang_data
[0]) - 1;
3244 *ppObj
= (LPVOID
) mlang
;
3245 TRACE("returning %p\n", mlang
);
3252 /******************************************************************************/
3254 HRESULT WINAPI
DllCanUnloadNow(void)
3256 return dll_count
== 0 ? S_OK
: S_FALSE
;
3259 HRESULT WINAPI
GetGlobalFontLinkObject(void)