4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2003,2004 Mike McCormack
6 * Copyright 2004,2005 Dmitry Timoshkov
7 * Copyright 2009 Detlef Riekenberg
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
38 #include "wine/unicode.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(mlang
);
45 #define CP_UNICODE 1200
47 static HRESULT
MultiLanguage_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
48 static HRESULT
EnumRfc1766_create(LANGID LangId
, IEnumRfc1766
**ppEnum
);
50 static DWORD MLANG_tls_index
; /* to store various per thead data */
53 * Under what circumstances HKEY_CLASSES_ROOT\MIME\Database\Codepage and
54 * HKEY_CLASSES_ROOT\MIME\Database\Charset are used?
59 const char *description
;
62 const char *web_charset
;
63 const char *header_charset
;
64 const char *body_charset
;
67 /* These data are based on the codepage info in libs/unicode/cpmap.pl */
68 /* FIXME: Add 28604 (Celtic), 28606 (Balkan) */
70 static const MIME_CP_INFO arabic_cp
[] =
73 864, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
74 MIMECONTF_MIME_LATEST
,
75 "ibm864", "ibm864", "ibm864" },
77 1006, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
78 MIMECONTF_MIME_LATEST
,
79 "ibm1006", "ibm1006", "ibm1006" },
81 1256, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
82 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
83 MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
84 "windows-1256", "windows-1256", "windows-1256" },
86 28596, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
87 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
88 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
89 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
90 "iso-8859-6", "iso-8859-6", "iso-8859-6" }
92 static const MIME_CP_INFO baltic_cp
[] =
95 775, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
96 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
97 "ibm775", "ibm775", "ibm775" },
99 1257, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
100 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
101 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
102 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
103 "windows-1257", "windows-1257", "windows-1257" },
105 28594, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
106 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
107 MIMECONTF_EXPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
108 MIMECONTF_MIME_LATEST
,
109 "iso-8859-4", "iso-8859-4", "iso-8859-4" },
111 28603, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
112 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
113 "iso-8859-13", "iso-8859-13", "iso-8859-13" }
115 static const MIME_CP_INFO chinese_simplified_cp
[] =
117 { "Chinese Simplified (GB2312)",
118 936, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
119 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
120 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
121 MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
122 "gb2312", "gb2312", "gb2312" }
124 static const MIME_CP_INFO chinese_traditional_cp
[] =
126 { "Chinese Traditional (Big5)",
127 950, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
128 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
129 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
130 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
131 "big5", "big5", "big5" }
133 static const MIME_CP_INFO central_european_cp
[] =
135 { "Central European (DOS)",
136 852, MIMECONTF_BROWSER
| MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_BROWSER
|
137 MIMECONTF_EXPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
138 MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
139 "ibm852", "ibm852", "ibm852" },
140 { "Central European (Windows)",
141 1250, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
142 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
143 MIMECONTF_EXPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
144 MIMECONTF_MIME_LATEST
,
145 "windows-1250", "windows-1250", "windows-1250" },
146 { "Central European (Mac)",
147 10029, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
148 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
149 "x-mac-ce", "x-mac-ce", "x-mac-ce" },
150 { "Central European (ISO)",
151 28592, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
152 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
153 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
154 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
155 "iso-8859-2", "iso-8859-2", "iso-8859-2" }
157 static const MIME_CP_INFO cyrillic_cp
[] =
160 855, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
161 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
162 "ibm855", "ibm855", "ibm855" },
164 866, MIMECONTF_BROWSER
| MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_BROWSER
|
165 MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
|
166 MIMECONTF_MIME_LATEST
,
167 "cp866", "cp866", "cp866" },
168 #if 0 /* Windows has 20866 as an official code page for KOI8-R */
169 { "Cyrillic (KOI8-R)",
170 878, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
171 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
172 "koi8-r", "koi8-r", "koi8-r" },
174 { "Cyrillic (Windows)",
175 1251, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
176 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
177 MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
178 "windows-1251", "windows-1251", "windows-1251" },
180 10007, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
181 MIMECONTF_MIME_LATEST
,
182 "x-mac-cyrillic", "x-mac-cyrillic", "x-mac-cyrillic" },
183 { "Cyrillic (KOI8-R)",
184 20866, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
185 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
186 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
187 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
188 "koi8-r", "koi8-r", "koi8-r" },
189 { "Cyrillic (KOI8-U)",
190 21866, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
191 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
192 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
193 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
194 "koi8-u", "koi8-u", "koi8-u" },
196 28595, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
197 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
198 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
199 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
200 "iso-8859-5", "iso-8859-5", "iso-8859-5" }
202 static const MIME_CP_INFO greek_cp
[] =
205 737, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
206 MIMECONTF_MIME_LATEST
,
207 "ibm737", "ibm737", "ibm737" },
208 { "Greek, Modern (DOS)",
209 869, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
210 MIMECONTF_MIME_LATEST
,
211 "ibm869", "ibm869", "ibm869" },
212 { "IBM EBCDIC (Greek Modern)",
213 875, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
214 MIMECONTF_MIME_LATEST
,
215 "cp875", "cp875", "cp875" },
217 1253, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
218 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
219 MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
220 "windows-1253", "windows-1253", "windows-1253" },
222 10006, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
223 MIMECONTF_MIME_LATEST
,
224 "x-mac-greek", "x-mac-greek", "x-mac-greek" },
226 28597, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
227 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
228 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
229 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
230 "iso-8859-7", "iso-8859-7", "iso-8859-7" }
232 static const MIME_CP_INFO hebrew_cp
[] =
235 424, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
236 MIMECONTF_MIME_LATEST
,
237 "ibm424", "ibm424", "ibm424" },
239 856, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
240 MIMECONTF_MIME_LATEST
,
241 "cp856", "cp856", "cp856" },
243 862, MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
| MIMECONTF_IMPORT
|
244 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
245 MIMECONTF_MIME_LATEST
,
246 "dos-862", "dos-862", "dos-862" },
247 { "Hebrew (Windows)",
248 1255, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
249 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
250 MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
251 "windows-1255", "windows-1255", "windows-1255" },
252 { "Hebrew (ISO-Visual)",
253 28598, MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
| MIMECONTF_IMPORT
|
254 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
255 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
256 "iso-8859-8", "iso-8859-8", "iso-8859-8" }
258 static const MIME_CP_INFO japanese_cp
[] =
260 { "Japanese (Auto-Select)",
261 50932, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
262 MIMECONTF_IMPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
263 MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
264 "_autodetect", "_autodetect", "_autodetect" },
266 51932, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
267 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
268 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
269 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
270 "euc-jp", "euc-jp", "euc-jp" },
272 50220, MIMECONTF_IMPORT
| MIMECONTF_MAILNEWS
| MIMECONTF_EXPORT
|
273 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_VALID_NLS
|
274 MIMECONTF_PRIVCONVERTER
| MIMECONTF_MIME_LATEST
|
276 "iso-2022-jp","iso-2022-jp","iso-2022-jp"},
277 { "Japanese (JIS 0208-1990 and 0212-1990)",
278 20932, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
279 MIMECONTF_VALID
| MIMECONTF_PRIVCONVERTER
| MIMECONTF_MIME_LATEST
,
280 "EUC-JP","EUC-JP","EUC-JP"},
281 { "Japanese (JIS-Allow 1 byte Kana)",
282 50221, MIMECONTF_MAILNEWS
| MIMECONTF_EXPORT
| MIMECONTF_SAVABLE_BROWSER
|
283 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_VALID_NLS
|
284 MIMECONTF_VALID
| MIMECONTF_PRIVCONVERTER
| MIMECONTF_MIME_LATEST
,
285 "csISO2022JP","iso-2022-jp","iso-2022-jp"},
286 { "Japanese (JIS-Allow 1 byte Kana - SO/SI)",
287 50222, MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
| MIMECONTF_VALID
|
288 MIMECONTF_PRIVCONVERTER
| MIMECONTF_MIME_LATEST
,
289 "iso-2022-jp","iso-2022-jp","iso-2022-jp"},
291 10001, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
292 MIMECONTF_VALID
| MIMECONTF_PRIVCONVERTER
| MIMECONTF_MIME_LATEST
,
293 "x-mac-japanese","x-mac-japanese","x-mac-japanese"},
294 { "Japanese (Shift-JIS)",
295 932, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
296 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
297 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
298 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
299 "shift_jis", "iso-2022-jp", "iso-2022-jp" }
301 static const MIME_CP_INFO korean_cp
[] =
304 949, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
305 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
306 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
307 MIMECONTF_MIME_LATEST
,
308 "ks_c_5601-1987", "ks_c_5601-1987", "ks_c_5601-1987" }
310 static const MIME_CP_INFO thai_cp
[] =
313 874, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_MIME_LATEST
,
314 "ibm-thai", "ibm-thai", "ibm-thai" }
316 static const MIME_CP_INFO turkish_cp
[] =
319 857, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
320 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
321 "ibm857", "ibm857", "ibm857" },
322 { "IBM EBCDIC (Turkish Latin-5)",
323 1026, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
324 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
325 "ibm1026", "ibm1026", "ibm1026" },
326 { "Turkish (Windows)",
327 1254, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
328 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
329 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
330 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
331 "windows-1254", "windows-1254", "windows-1254" },
333 10081, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
334 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
335 "x-mac-turkish", "x-mac-turkish", "x-mac-turkish" },
337 28593, MIMECONTF_MAILNEWS
| MIMECONTF_IMPORT
|
338 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
339 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
340 "iso-8859-3", "iso-8859-3", "iso-8859-3" },
342 28599, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
343 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
344 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
345 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
346 "iso-8859-9", "iso-8859-9", "iso-8859-9" }
348 static const MIME_CP_INFO vietnamese_cp
[] =
350 { "Vietnamese (Windows)",
351 1258, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
352 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
353 MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
|
354 MIMECONTF_MIME_LATEST
,
355 "windows-1258", "windows-1258", "windows-1258" }
357 static const MIME_CP_INFO western_cp
[] =
359 { "IBM EBCDIC (US-Canada)",
360 37, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
361 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
362 "ibm037", "ibm037", "ibm037" },
363 { "OEM United States",
364 437, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
365 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
366 "ibm437", "ibm437", "ibm437" },
367 { "IBM EBCDIC (International)",
368 500, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
369 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
370 "ibm500", "ibm500", "ibm500" },
371 { "Western European (DOS)",
372 850, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
373 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
374 "ibm850", "ibm850", "ibm850" },
375 { "Portuguese (DOS)",
376 860, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
377 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
378 "ibm860", "ibm860", "ibm860" },
380 861, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
381 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
382 "ibm861", "ibm861", "ibm861" },
383 { "French Canadian (DOS)",
384 863, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
385 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
386 "ibm863", "ibm863", "ibm863" },
388 865, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
389 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
390 "ibm865", "ibm865", "ibm865" },
391 { "Western European (Windows)",
392 1252, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
393 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
394 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
395 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
396 "windows-1252", "windows-1252", "iso-8859-1" },
397 { "Western European (Mac)",
398 10000, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
399 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
400 "macintosh", "macintosh", "macintosh" },
402 10079, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
403 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
404 "x-mac-icelandic", "x-mac-icelandic", "x-mac-icelandic" },
406 20127, MIMECONTF_MAILNEWS
| MIMECONTF_IMPORT
| MIMECONTF_EXPORT
|
407 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_VALID
|
408 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
409 "us-ascii", "us-ascii", "us-ascii" },
410 { "Western European (ISO)",
411 28591, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
412 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
413 MIMECONTF_EXPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
414 MIMECONTF_MIME_LATEST
,
415 "iso-8859-1", "iso-8859-1", "iso-8859-1" },
417 28605, MIMECONTF_MAILNEWS
| MIMECONTF_IMPORT
|
418 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
419 MIMECONTF_EXPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
420 MIMECONTF_MIME_LATEST
,
421 "iso-8859-15", "iso-8859-15", "iso-8859-15" }
423 static const MIME_CP_INFO unicode_cp
[] =
426 CP_UNICODE
, MIMECONTF_MINIMAL
| MIMECONTF_IMPORT
|
427 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
428 MIMECONTF_VALID
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
|
429 MIMECONTF_MIME_LATEST
,
430 "unicode", "unicode", "unicode" },
432 CP_UTF7
, MIMECONTF_MAILNEWS
| MIMECONTF_IMPORT
|
433 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
434 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
435 "utf-7", "utf-7", "utf-7" },
437 CP_UTF8
, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
438 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
439 MIMECONTF_EXPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
440 MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
441 "utf-8", "utf-8", "utf-8" }
444 static const struct mlang_data
446 const char *description
;
447 UINT family_codepage
;
449 const MIME_CP_INFO
*mime_cp_info
;
450 const char *fixed_font
;
451 const char *proportional_font
;
455 { "Arabic",1256,sizeof(arabic_cp
)/sizeof(arabic_cp
[0]),arabic_cp
,
456 "Courier","Arial", sidArabic
}, /* 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", sidCyrillic
}, /* FIXME */
467 { "Greek",1253,sizeof(greek_cp
)/sizeof(greek_cp
[0]),greek_cp
,
468 "Courier","Arial", sidGreek
}, /* FIXME */
469 { "Hebrew",1255,sizeof(hebrew_cp
)/sizeof(hebrew_cp
[0]),hebrew_cp
,
470 "Courier","Arial", sidHebrew
}, /* 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", sidThai
}, /* 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", sidLatin
}, /* 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
);
807 rc
= MultiByteToWideChar(CP_ACP
,0,input
,count
,output
,out_count
);
809 rc
= MultiByteToWideChar(CP_ACP
,0,input
,count
,0,0);
814 rc
= MultiByteToWideChar(932,0,input
,count
,output
,out_count
);
816 rc
= MultiByteToWideChar(932,0,input
,count
,0,0);
821 rc
= MultiByteToWideChar(20932,0,input
,count
,output
,out_count
);
823 rc
= MultiByteToWideChar(20932,0,input
,count
,0,0);
827 sjis_string
= HeapAlloc(GetProcessHeap(),0,count
);
828 rc
= ConvertJIS2SJIS(input
,count
,sjis_string
);
831 TRACE("%s\n",debugstr_an(sjis_string
,rc
));
833 rc
= MultiByteToWideChar(932,0,sjis_string
,rc
,output
,out_count
);
835 rc
= MultiByteToWideChar(932,0,sjis_string
,rc
,0,0);
837 HeapFree(GetProcessHeap(),0,sjis_string
);
843 static UINT
ConvertJapaneseUnicodeToJIS(LPCWSTR input
, DWORD count
,
844 LPSTR output
, DWORD out_count
)
850 len
= WideCharToMultiByte(932,0,input
,count
,0,0,NULL
,NULL
);
851 sjis_string
= HeapAlloc(GetProcessHeap(),0,len
);
852 WideCharToMultiByte(932,0,input
,count
,sjis_string
,len
,NULL
,NULL
);
853 TRACE("%s\n",debugstr_an(sjis_string
,len
));
855 rc
= ConvertSJIS2JIS(sjis_string
, len
, NULL
);
858 ConvertSJIS2JIS(sjis_string
, len
, output
);
860 HeapFree(GetProcessHeap(),0,sjis_string
);
866 * Dll lifetime tracking declaration
868 static void LockModule(void)
870 InterlockedIncrement(&dll_count
);
873 static void UnlockModule(void)
875 InterlockedDecrement(&dll_count
);
878 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
881 case DLL_PROCESS_ATTACH
:
882 MLANG_tls_index
= TlsAlloc();
883 DisableThreadLibraryCalls(hInstDLL
);
885 case DLL_PROCESS_DETACH
:
886 TlsFree(MLANG_tls_index
);
892 HRESULT WINAPI
ConvertINetMultiByteToUnicode(
902 TRACE("%p %d %s %p %p %p\n", pdwMode
, dwEncoding
,
903 debugstr_a(pSrcStr
), pcSrcSize
, pDstStr
, pcDstSize
);
909 pcSrcSize
= &src_len
;
917 /* forwarding euc-jp to EUC-JP */
918 if (dwEncoding
== 51932)
924 if (*pcSrcSize
== -1)
925 *pcSrcSize
= lstrlenW((LPCWSTR
)pSrcStr
);
926 *pcDstSize
= min(*pcSrcSize
, *pcDstSize
);
927 *pcSrcSize
*= sizeof(WCHAR
);
929 memmove(pDstStr
, pSrcStr
, *pcDstSize
* sizeof(WCHAR
));
935 *pcDstSize
= ConvertJISJapaneseToUnicode(pSrcStr
,*pcSrcSize
,pDstStr
,*pcDstSize
);
938 *pcDstSize
= ConvertUnknownJapaneseToUnicode(pSrcStr
,*pcSrcSize
,pDstStr
,*pcDstSize
);
942 if (*pcSrcSize
== -1)
943 *pcSrcSize
= lstrlenA(pSrcStr
);
946 *pcDstSize
= MultiByteToWideChar(dwEncoding
, 0, pSrcStr
, *pcSrcSize
, pDstStr
, *pcDstSize
);
948 *pcDstSize
= MultiByteToWideChar(dwEncoding
, 0, pSrcStr
, *pcSrcSize
, NULL
, 0);
958 HRESULT WINAPI
ConvertINetUnicodeToMultiByte(
969 TRACE("%p %d %s %p %p %p\n", pdwMode
, dwEncoding
,
970 debugstr_w(pSrcStr
), pcSrcSize
, pDstStr
, pcDstSize
);
976 pcSrcSize
= &src_len
;
978 destsz
= (pDstStr
) ? *pcDstSize
: 0;
981 if (!pSrcStr
|| !*pcSrcSize
)
984 if (*pcSrcSize
== -1)
985 *pcSrcSize
= lstrlenW(pSrcStr
);
987 /* forwarding euc-jp to EUC-JP */
988 if (dwEncoding
== 51932)
991 if (dwEncoding
== CP_UNICODE
)
993 if (*pcSrcSize
== -1)
994 *pcSrcSize
= lstrlenW(pSrcStr
);
996 size
= min(*pcSrcSize
, destsz
) * sizeof(WCHAR
);
998 memmove(pDstStr
, pSrcStr
, size
);
1003 else if (dwEncoding
== 50220 || dwEncoding
== 50221 || dwEncoding
== 50222)
1005 size
= ConvertJapaneseUnicodeToJIS(pSrcStr
, *pcSrcSize
, NULL
, 0);
1011 size
= ConvertJapaneseUnicodeToJIS(pSrcStr
, *pcSrcSize
, pDstStr
,
1020 size
= WideCharToMultiByte(dwEncoding
, 0, pSrcStr
, *pcSrcSize
,
1021 NULL
, 0, NULL
, NULL
);
1027 size
= WideCharToMultiByte(dwEncoding
, 0, pSrcStr
, *pcSrcSize
,
1028 pDstStr
, destsz
, NULL
, NULL
);
1043 HRESULT WINAPI
ConvertINetString(
1045 DWORD dwSrcEncoding
,
1046 DWORD dwDstEncoding
,
1053 TRACE("%p %d %d %s %p %p %p\n", pdwMode
, dwSrcEncoding
, dwDstEncoding
,
1054 debugstr_a(pSrcStr
), pcSrcSize
, pDstStr
, pcDstSize
);
1056 if (dwSrcEncoding
== CP_UNICODE
)
1059 if (pcSrcSize
&& *pcSrcSize
!= -1)
1061 cSrcSizeW
= *pcSrcSize
/ sizeof(WCHAR
);
1062 pcSrcSize
= &cSrcSizeW
;
1064 return ConvertINetUnicodeToMultiByte(pdwMode
, dwDstEncoding
, (LPCWSTR
)pSrcStr
, pcSrcSize
, pDstStr
, pcDstSize
);
1066 else if (dwDstEncoding
== CP_UNICODE
)
1068 HRESULT hr
= ConvertINetMultiByteToUnicode(pdwMode
, dwSrcEncoding
, pSrcStr
, pcSrcSize
, (LPWSTR
)pDstStr
, pcDstSize
);
1069 *pcDstSize
*= sizeof(WCHAR
);
1078 TRACE("convert %s from %d to %d\n", debugstr_a(pSrcStr
), dwSrcEncoding
, dwDstEncoding
);
1080 hr
= ConvertINetMultiByteToUnicode(pdwMode
, dwSrcEncoding
, pSrcStr
, pcSrcSize
, NULL
, &cDstSizeW
);
1084 pDstStrW
= HeapAlloc(GetProcessHeap(), 0, cDstSizeW
* sizeof(WCHAR
));
1085 hr
= ConvertINetMultiByteToUnicode(pdwMode
, dwSrcEncoding
, pSrcStr
, pcSrcSize
, pDstStrW
, &cDstSizeW
);
1087 hr
= ConvertINetUnicodeToMultiByte(pdwMode
, dwDstEncoding
, pDstStrW
, &cDstSizeW
, pDstStr
, pcDstSize
);
1089 HeapFree(GetProcessHeap(), 0, pDstStrW
);
1094 static HRESULT
GetFamilyCodePage(
1096 UINT
* puiFamilyCodePage
)
1100 TRACE("%u %p\n", uiCodePage
, puiFamilyCodePage
);
1102 if (!puiFamilyCodePage
) return S_FALSE
;
1104 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
1106 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
1108 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
1110 *puiFamilyCodePage
= mlang_data
[i
].family_codepage
;
1119 HRESULT WINAPI
IsConvertINetStringAvailable(
1120 DWORD dwSrcEncoding
,
1121 DWORD dwDstEncoding
)
1123 UINT src_family
, dst_family
;
1125 TRACE("%d %d\n", dwSrcEncoding
, dwDstEncoding
);
1127 if (GetFamilyCodePage(dwSrcEncoding
, &src_family
) != S_OK
||
1128 GetFamilyCodePage(dwDstEncoding
, &dst_family
) != S_OK
)
1131 if (src_family
== dst_family
) return S_OK
;
1133 /* we can convert any codepage to/from unicode */
1134 if (src_family
== CP_UNICODE
|| dst_family
== CP_UNICODE
) return S_OK
;
1139 static inline HRESULT
lcid_to_rfc1766A( LCID lcid
, LPSTR rfc1766
, INT len
)
1141 CHAR buffer
[MAX_RFC1766_NAME
];
1142 INT n
= GetLocaleInfoA(lcid
, LOCALE_SISO639LANGNAME
, buffer
, MAX_RFC1766_NAME
);
1147 i
= PRIMARYLANGID(lcid
);
1148 if ((((i
== LANG_ENGLISH
) || (i
== LANG_CHINESE
) || (i
== LANG_ARABIC
)) &&
1149 (SUBLANGID(lcid
) == SUBLANG_DEFAULT
)) ||
1150 (SUBLANGID(lcid
) > SUBLANG_DEFAULT
)) {
1152 buffer
[n
- 1] = '-';
1153 i
= GetLocaleInfoA(lcid
, LOCALE_SISO3166CTRYNAME
, buffer
+ n
, MAX_RFC1766_NAME
- n
);
1155 buffer
[n
- 1] = '\0';
1160 LCMapStringA( LOCALE_USER_DEFAULT
, LCMAP_LOWERCASE
, buffer
, n
+ i
, rfc1766
, len
);
1161 return ((n
+ i
) > len
) ? E_INVALIDARG
: S_OK
;
1166 static inline HRESULT
lcid_to_rfc1766W( LCID lcid
, LPWSTR rfc1766
, INT len
)
1168 WCHAR buffer
[MAX_RFC1766_NAME
];
1169 INT n
= GetLocaleInfoW(lcid
, LOCALE_SISO639LANGNAME
, buffer
, MAX_RFC1766_NAME
);
1174 i
= PRIMARYLANGID(lcid
);
1175 if ((((i
== LANG_ENGLISH
) || (i
== LANG_CHINESE
) || (i
== LANG_ARABIC
)) &&
1176 (SUBLANGID(lcid
) == SUBLANG_DEFAULT
)) ||
1177 (SUBLANGID(lcid
) > SUBLANG_DEFAULT
)) {
1179 buffer
[n
- 1] = '-';
1180 i
= GetLocaleInfoW(lcid
, LOCALE_SISO3166CTRYNAME
, buffer
+ n
, MAX_RFC1766_NAME
- n
);
1182 buffer
[n
- 1] = '\0';
1187 LCMapStringW(LOCALE_USER_DEFAULT
, LCMAP_LOWERCASE
, buffer
, n
+ i
, rfc1766
, len
);
1188 return ((n
+ i
) > len
) ? E_INVALIDARG
: S_OK
;
1193 HRESULT WINAPI
LcidToRfc1766A(
1198 TRACE("%04x %p %u\n", lcid
, pszRfc1766
, nChar
);
1200 return E_INVALIDARG
;
1202 return lcid_to_rfc1766A(lcid
, pszRfc1766
, nChar
);
1205 HRESULT WINAPI
LcidToRfc1766W(
1210 TRACE("%04x %p %u\n", lcid
, pszRfc1766
, nChar
);
1212 return E_INVALIDARG
;
1214 return lcid_to_rfc1766W(lcid
, pszRfc1766
, nChar
);
1217 static HRESULT
lcid_from_rfc1766(IEnumRfc1766
*iface
, LCID
*lcid
, LPCWSTR rfc1766
)
1222 while (IEnumRfc1766_Next(iface
, 1, &info
, &num
) == S_OK
)
1224 if (!strcmpiW(info
.wszRfc1766
, rfc1766
))
1229 if (strlenW(rfc1766
) == 2 && !memcmp(info
.wszRfc1766
, rfc1766
, 2 * sizeof(WCHAR
)))
1231 *lcid
= PRIMARYLANGID(info
.lcid
);
1239 HRESULT WINAPI
Rfc1766ToLcidW(LCID
*pLocale
, LPCWSTR pszRfc1766
)
1241 IEnumRfc1766
*enumrfc1766
;
1244 TRACE("(%p, %s)\n", pLocale
, debugstr_w(pszRfc1766
));
1246 if (!pLocale
|| !pszRfc1766
)
1247 return E_INVALIDARG
;
1249 hr
= EnumRfc1766_create(0, &enumrfc1766
);
1253 hr
= lcid_from_rfc1766(enumrfc1766
, pLocale
, pszRfc1766
);
1254 IEnumRfc1766_Release(enumrfc1766
);
1259 HRESULT WINAPI
Rfc1766ToLcidA(LCID
*lcid
, LPCSTR rfc1766A
)
1261 WCHAR rfc1766W
[MAX_RFC1766_NAME
+ 1];
1264 return E_INVALIDARG
;
1266 MultiByteToWideChar(CP_ACP
, 0, rfc1766A
, -1, rfc1766W
, MAX_RFC1766_NAME
);
1267 rfc1766W
[MAX_RFC1766_NAME
] = 0;
1269 return Rfc1766ToLcidW(lcid
, rfc1766W
);
1272 /******************************************************************************
1273 * MLANG ClassFactory
1276 IClassFactory ITF_IClassFactory
;
1279 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
1280 } IClassFactoryImpl
;
1282 struct object_creation_info
1286 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
1289 static const struct object_creation_info object_creation
[] =
1291 { &CLSID_CMultiLanguage
, "CLSID_CMultiLanguage", MultiLanguage_create
},
1294 static HRESULT WINAPI
1295 MLANGCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
)
1297 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
1299 TRACE("%s\n", debugstr_guid(riid
) );
1301 if (IsEqualGUID(riid
, &IID_IUnknown
)
1302 || IsEqualGUID(riid
, &IID_IClassFactory
))
1304 IClassFactory_AddRef(iface
);
1309 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
1310 return E_NOINTERFACE
;
1313 static ULONG WINAPI
MLANGCF_AddRef(LPCLASSFACTORY iface
)
1315 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
1316 return InterlockedIncrement(&This
->ref
);
1319 static ULONG WINAPI
MLANGCF_Release(LPCLASSFACTORY iface
)
1321 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
1323 ULONG ref
= InterlockedDecrement(&This
->ref
);
1327 TRACE("Destroying %p\n", This
);
1328 HeapFree(GetProcessHeap(), 0, This
);
1334 static HRESULT WINAPI
MLANGCF_CreateInstance(LPCLASSFACTORY iface
, LPUNKNOWN pOuter
,
1335 REFIID riid
, LPVOID
*ppobj
)
1337 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
1341 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
1344 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
1345 if (SUCCEEDED(hres
)) {
1346 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
1347 IUnknown_Release(punk
);
1349 TRACE("returning (%p) -> %x\n", *ppobj
, hres
);
1353 static HRESULT WINAPI
MLANGCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
)
1363 static const IClassFactoryVtbl MLANGCF_Vtbl
=
1365 MLANGCF_QueryInterface
,
1368 MLANGCF_CreateInstance
,
1372 /******************************************************************
1373 * DllGetClassObject (MLANG.@)
1375 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
1378 IClassFactoryImpl
*factory
;
1380 TRACE("%s %s %p\n",debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
1382 if ( !IsEqualGUID( &IID_IClassFactory
, iid
)
1383 && ! IsEqualGUID( &IID_IUnknown
, iid
) )
1384 return E_NOINTERFACE
;
1386 for (i
=0; i
< sizeof(object_creation
)/sizeof(object_creation
[0]); i
++)
1388 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
1392 if (i
== sizeof(object_creation
)/sizeof(object_creation
[0]))
1394 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
1395 return CLASS_E_CLASSNOTAVAILABLE
;
1398 TRACE("Creating a class factory for %s\n",object_creation
[i
].szClassName
);
1400 factory
= HeapAlloc(GetProcessHeap(), 0, sizeof(*factory
));
1401 if (factory
== NULL
) return E_OUTOFMEMORY
;
1403 factory
->ITF_IClassFactory
.lpVtbl
= &MLANGCF_Vtbl
;
1406 factory
->pfnCreateInstance
= object_creation
[i
].pfnCreateInstance
;
1408 *ppv
= &(factory
->ITF_IClassFactory
);
1410 TRACE("(%p) <- %p\n", ppv
, &(factory
->ITF_IClassFactory
) );
1416 /******************************************************************************/
1418 typedef struct tagMLang_impl
1420 const IMLangFontLinkVtbl
*vtbl_IMLangFontLink
;
1421 const IMultiLanguageVtbl
*vtbl_IMultiLanguage
;
1422 const IMultiLanguage3Vtbl
*vtbl_IMultiLanguage3
;
1423 const IMLangFontLink2Vtbl
*vtbl_IMLangFontLink2
;
1424 const IMLangLineBreakConsoleVtbl
*vtbl_IMLangLineBreakConsole
;
1426 DWORD total_cp
, total_scripts
;
1429 static ULONG
MLang_AddRef( MLang_impl
* This
)
1431 return InterlockedIncrement(&This
->ref
);
1434 static ULONG
MLang_Release( MLang_impl
* This
)
1436 ULONG ref
= InterlockedDecrement(&This
->ref
);
1438 TRACE("%p ref = %d\n", This
, ref
);
1441 TRACE("Destroying %p\n", This
);
1442 HeapFree(GetProcessHeap(), 0, This
);
1449 static HRESULT
MLang_QueryInterface(
1454 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
1456 if (IsEqualGUID(riid
, &IID_IUnknown
)
1457 || IsEqualGUID(riid
, &IID_IMLangCodePages
)
1458 || IsEqualGUID(riid
, &IID_IMLangFontLink
))
1461 TRACE("Returning IID_IMLangFontLink %p ref = %d\n", This
, This
->ref
);
1462 *ppvObject
= &(This
->vtbl_IMLangFontLink
);
1466 if (IsEqualGUID(riid
, &IID_IMLangFontLink2
))
1469 TRACE("Returning IID_IMLangFontLink2 %p ref = %d\n", This
, This
->ref
);
1470 *ppvObject
= &(This
->vtbl_IMLangFontLink2
);
1474 if (IsEqualGUID(riid
, &IID_IMultiLanguage
) )
1477 TRACE("Returning IID_IMultiLanguage %p ref = %d\n", This
, This
->ref
);
1478 *ppvObject
= &(This
->vtbl_IMultiLanguage
);
1482 if (IsEqualGUID(riid
, &IID_IMultiLanguage2
) )
1485 *ppvObject
= &(This
->vtbl_IMultiLanguage3
);
1486 TRACE("Returning IID_IMultiLanguage2 %p ref = %d\n", This
, This
->ref
);
1490 if (IsEqualGUID(riid
, &IID_IMultiLanguage3
) )
1493 *ppvObject
= &(This
->vtbl_IMultiLanguage3
);
1494 TRACE("Returning IID_IMultiLanguage3 %p ref = %d\n", This
, This
->ref
);
1498 if (IsEqualGUID(riid
, &IID_IMLangLineBreakConsole
))
1501 TRACE("Returning IID_IMLangLineBreakConsole %p ref = %d\n", This
, This
->ref
);
1502 *ppvObject
= &(This
->vtbl_IMLangLineBreakConsole
);
1507 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1508 return E_NOINTERFACE
;
1511 /******************************************************************************/
1513 typedef struct tagEnumCodePage_impl
1515 const IEnumCodePageVtbl
*vtbl_IEnumCodePage
;
1519 } EnumCodePage_impl
;
1521 static inline EnumCodePage_impl
*impl_from_IEnumCodePage( IEnumCodePage
*iface
)
1523 return CONTAINING_RECORD( iface
, EnumCodePage_impl
, vtbl_IEnumCodePage
);
1526 static HRESULT WINAPI
fnIEnumCodePage_QueryInterface(
1527 IEnumCodePage
* iface
,
1531 EnumCodePage_impl
*This
= impl_from_IEnumCodePage( iface
);
1533 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
1535 if (IsEqualGUID(riid
, &IID_IUnknown
)
1536 || IsEqualGUID(riid
, &IID_IEnumCodePage
))
1538 IEnumCodePage_AddRef(iface
);
1539 TRACE("Returning IID_IEnumCodePage %p ref = %d\n", This
, This
->ref
);
1540 *ppvObject
= &(This
->vtbl_IEnumCodePage
);
1544 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1545 return E_NOINTERFACE
;
1548 static ULONG WINAPI
fnIEnumCodePage_AddRef(
1549 IEnumCodePage
* iface
)
1551 EnumCodePage_impl
*This
= impl_from_IEnumCodePage( iface
);
1552 return InterlockedIncrement(&This
->ref
);
1555 static ULONG WINAPI
fnIEnumCodePage_Release(
1556 IEnumCodePage
* iface
)
1558 EnumCodePage_impl
*This
= impl_from_IEnumCodePage( iface
);
1559 ULONG ref
= InterlockedDecrement(&This
->ref
);
1561 TRACE("%p ref = %d\n", This
, ref
);
1564 TRACE("Destroying %p\n", This
);
1565 HeapFree(GetProcessHeap(), 0, This
->cpinfo
);
1566 HeapFree(GetProcessHeap(), 0, This
);
1572 static HRESULT WINAPI
fnIEnumCodePage_Clone(
1573 IEnumCodePage
* iface
,
1574 IEnumCodePage
** ppEnum
)
1576 EnumCodePage_impl
*This
= impl_from_IEnumCodePage( iface
);
1577 FIXME("%p %p\n", This
, ppEnum
);
1581 static HRESULT WINAPI
fnIEnumCodePage_Next(
1582 IEnumCodePage
* iface
,
1585 ULONG
* pceltFetched
)
1588 EnumCodePage_impl
*This
= impl_from_IEnumCodePage( iface
);
1590 TRACE("%p %u %p %p\n", This
, celt
, rgelt
, pceltFetched
);
1592 if (!pceltFetched
) return S_FALSE
;
1595 if (!rgelt
) return S_FALSE
;
1597 if (This
->pos
+ celt
> This
->total
)
1598 celt
= This
->total
- This
->pos
;
1600 if (!celt
) return S_FALSE
;
1602 memcpy(rgelt
, This
->cpinfo
+ This
->pos
, celt
* sizeof(MIMECPINFO
));
1603 *pceltFetched
= celt
;
1606 for (i
= 0; i
< celt
; i
++)
1608 TRACE("#%u: %08x %u %u %s %s %s %s %s %s %d\n",
1609 i
, rgelt
[i
].dwFlags
, rgelt
[i
].uiCodePage
,
1610 rgelt
[i
].uiFamilyCodePage
,
1611 wine_dbgstr_w(rgelt
[i
].wszDescription
),
1612 wine_dbgstr_w(rgelt
[i
].wszWebCharset
),
1613 wine_dbgstr_w(rgelt
[i
].wszHeaderCharset
),
1614 wine_dbgstr_w(rgelt
[i
].wszBodyCharset
),
1615 wine_dbgstr_w(rgelt
[i
].wszFixedWidthFont
),
1616 wine_dbgstr_w(rgelt
[i
].wszProportionalFont
),
1617 rgelt
[i
].bGDICharset
);
1622 static HRESULT WINAPI
fnIEnumCodePage_Reset(
1623 IEnumCodePage
* iface
)
1625 EnumCodePage_impl
*This
= impl_from_IEnumCodePage( iface
);
1627 TRACE("%p\n", This
);
1633 static HRESULT WINAPI
fnIEnumCodePage_Skip(
1634 IEnumCodePage
* iface
,
1637 EnumCodePage_impl
*This
= impl_from_IEnumCodePage( iface
);
1639 TRACE("%p %u\n", This
, celt
);
1641 if (celt
>= This
->total
) return S_FALSE
;
1647 static const IEnumCodePageVtbl IEnumCodePage_vtbl
=
1649 fnIEnumCodePage_QueryInterface
,
1650 fnIEnumCodePage_AddRef
,
1651 fnIEnumCodePage_Release
,
1652 fnIEnumCodePage_Clone
,
1653 fnIEnumCodePage_Next
,
1654 fnIEnumCodePage_Reset
,
1655 fnIEnumCodePage_Skip
1658 static HRESULT
EnumCodePage_create( MLang_impl
* mlang
, DWORD grfFlags
,
1659 LANGID LangId
, IEnumCodePage
** ppEnumCodePage
)
1661 EnumCodePage_impl
*ecp
;
1665 TRACE("%p, %08x, %04x, %p\n", mlang
, grfFlags
, LangId
, ppEnumCodePage
);
1667 if (!grfFlags
) /* enumerate internal data base of encodings */
1668 grfFlags
= MIMECONTF_MIME_LATEST
;
1670 ecp
= HeapAlloc( GetProcessHeap(), 0, sizeof (EnumCodePage_impl
) );
1671 ecp
->vtbl_IEnumCodePage
= &IEnumCodePage_vtbl
;
1675 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
1677 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
1679 if (mlang_data
[i
].mime_cp_info
[n
].flags
& grfFlags
)
1684 ecp
->cpinfo
= HeapAlloc(GetProcessHeap(), 0,
1685 sizeof(MIMECPINFO
) * ecp
->total
);
1686 cpinfo
= ecp
->cpinfo
;
1688 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
1690 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
1692 if (mlang_data
[i
].mime_cp_info
[n
].flags
& grfFlags
)
1693 fill_cp_info(&mlang_data
[i
], n
, cpinfo
++);
1697 TRACE("enumerated %d codepages with flags %08x\n", ecp
->total
, grfFlags
);
1699 *ppEnumCodePage
= (IEnumCodePage
*) ecp
;
1704 /******************************************************************************/
1706 typedef struct tagEnumScript_impl
1708 const IEnumScriptVtbl
*vtbl_IEnumScript
;
1710 SCRIPTINFO
*script_info
;
1714 static inline EnumScript_impl
*impl_from_IEnumScript( IEnumScript
*iface
)
1716 return CONTAINING_RECORD( iface
, EnumScript_impl
, vtbl_IEnumScript
);
1719 static HRESULT WINAPI
fnIEnumScript_QueryInterface(
1724 EnumScript_impl
*This
= impl_from_IEnumScript( iface
);
1726 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
1728 if (IsEqualGUID(riid
, &IID_IUnknown
)
1729 || IsEqualGUID(riid
, &IID_IEnumScript
))
1731 IEnumScript_AddRef(iface
);
1732 TRACE("Returning IID_IEnumScript %p ref = %d\n", This
, This
->ref
);
1733 *ppvObject
= &(This
->vtbl_IEnumScript
);
1737 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1738 return E_NOINTERFACE
;
1741 static ULONG WINAPI
fnIEnumScript_AddRef(
1744 EnumScript_impl
*This
= impl_from_IEnumScript( iface
);
1745 return InterlockedIncrement(&This
->ref
);
1748 static ULONG WINAPI
fnIEnumScript_Release(
1751 EnumScript_impl
*This
= impl_from_IEnumScript( iface
);
1752 ULONG ref
= InterlockedDecrement(&This
->ref
);
1754 TRACE("%p ref = %d\n", This
, ref
);
1757 TRACE("Destroying %p\n", This
);
1758 HeapFree(GetProcessHeap(), 0, This
->script_info
);
1759 HeapFree(GetProcessHeap(), 0, This
);
1765 static HRESULT WINAPI
fnIEnumScript_Clone(
1767 IEnumScript
** ppEnum
)
1769 EnumScript_impl
*This
= impl_from_IEnumScript( iface
);
1770 FIXME("%p %p: stub!\n", This
, ppEnum
);
1774 static HRESULT WINAPI
fnIEnumScript_Next(
1778 ULONG
* pceltFetched
)
1780 EnumScript_impl
*This
= impl_from_IEnumScript( iface
);
1782 TRACE("%p %u %p %p\n", This
, celt
, rgelt
, pceltFetched
);
1784 if (!pceltFetched
|| !rgelt
) return E_FAIL
;
1788 if (This
->pos
+ celt
> This
->total
)
1789 celt
= This
->total
- This
->pos
;
1791 if (!celt
) return S_FALSE
;
1793 memcpy(rgelt
, This
->script_info
+ This
->pos
, celt
* sizeof(SCRIPTINFO
));
1794 *pceltFetched
= celt
;
1800 static HRESULT WINAPI
fnIEnumScript_Reset(
1803 EnumScript_impl
*This
= impl_from_IEnumScript( iface
);
1805 TRACE("%p\n", This
);
1811 static HRESULT WINAPI
fnIEnumScript_Skip(
1815 EnumScript_impl
*This
= impl_from_IEnumScript( iface
);
1817 TRACE("%p %u\n", This
, celt
);
1819 if (celt
>= This
->total
) return S_FALSE
;
1825 static const IEnumScriptVtbl IEnumScript_vtbl
=
1827 fnIEnumScript_QueryInterface
,
1828 fnIEnumScript_AddRef
,
1829 fnIEnumScript_Release
,
1830 fnIEnumScript_Clone
,
1832 fnIEnumScript_Reset
,
1836 static HRESULT
EnumScript_create( MLang_impl
* mlang
, DWORD dwFlags
,
1837 LANGID LangId
, IEnumScript
** ppEnumScript
)
1839 EnumScript_impl
*es
;
1842 TRACE("%p, %08x, %04x, %p: stub!\n", mlang
, dwFlags
, LangId
, ppEnumScript
);
1844 if (!dwFlags
) /* enumerate all available scripts */
1845 dwFlags
= SCRIPTCONTF_SCRIPT_USER
| SCRIPTCONTF_SCRIPT_HIDE
| SCRIPTCONTF_SCRIPT_SYSTEM
;
1847 es
= HeapAlloc( GetProcessHeap(), 0, sizeof (EnumScript_impl
) );
1848 es
->vtbl_IEnumScript
= &IEnumScript_vtbl
;
1851 /* do not enumerate unicode flavours */
1852 es
->total
= sizeof(mlang_data
)/sizeof(mlang_data
[0]) - 1;
1853 es
->script_info
= HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPTINFO
) * es
->total
);
1855 for (i
= 0; i
< es
->total
; i
++)
1857 es
->script_info
[i
].ScriptId
= i
;
1858 es
->script_info
[i
].uiCodePage
= mlang_data
[i
].family_codepage
;
1859 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].description
, -1,
1860 es
->script_info
[i
].wszDescription
, MAX_SCRIPT_NAME
);
1861 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].fixed_font
, -1,
1862 es
->script_info
[i
].wszFixedWidthFont
, MAX_MIMEFACE_NAME
);
1863 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].proportional_font
, -1,
1864 es
->script_info
[i
].wszProportionalFont
, MAX_MIMEFACE_NAME
);
1867 TRACE("enumerated %d scripts with flags %08x\n", es
->total
, dwFlags
);
1869 *ppEnumScript
= (IEnumScript
*)es
;
1874 /******************************************************************************/
1876 static inline MLang_impl
*impl_from_IMLangFontLink( IMLangFontLink
*iface
)
1878 return CONTAINING_RECORD( iface
, MLang_impl
, vtbl_IMLangFontLink
);
1881 static HRESULT WINAPI
fnIMLangFontLink_QueryInterface(
1882 IMLangFontLink
* iface
,
1886 MLang_impl
*This
= impl_from_IMLangFontLink( iface
);
1887 return MLang_QueryInterface( This
, riid
, ppvObject
);
1890 static ULONG WINAPI
fnIMLangFontLink_AddRef(
1891 IMLangFontLink
* iface
)
1893 MLang_impl
*This
= impl_from_IMLangFontLink( iface
);
1894 return MLang_AddRef( This
);
1897 static ULONG WINAPI
fnIMLangFontLink_Release(
1898 IMLangFontLink
* iface
)
1900 MLang_impl
*This
= impl_from_IMLangFontLink( iface
);
1901 return MLang_Release( This
);
1904 static HRESULT WINAPI
fnIMLangFontLink_GetCharCodePages(
1905 IMLangFontLink
* iface
,
1907 DWORD
* pdwCodePages
)
1916 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
1918 WideCharToMultiByte(mlang_data
[i
].family_codepage
, WC_NO_BEST_FIT_CHARS
,
1919 &chSrc
, 1, &buf
, 1, NULL
, &used_dc
);
1921 /* If default char is not used, current codepage include the given symbol */
1924 IMLangFontLink_CodePageToCodePages(iface
,
1925 mlang_data
[i
].family_codepage
, &codePages
);
1926 *pdwCodePages
|= codePages
;
1932 static HRESULT WINAPI
fnIMLangFontLink_GetStrCodePages(
1933 IMLangFontLink
* iface
,
1934 const WCHAR
* pszSrc
,
1936 DWORD dwPriorityCodePages
,
1937 DWORD
* pdwCodePages
,
1938 LONG
* pcchCodePages
)
1943 TRACE("(%p)->%s %d %x %p %p\n", iface
, debugstr_wn(pszSrc
, cchSrc
), cchSrc
, dwPriorityCodePages
, pdwCodePages
, pcchCodePages
);
1945 if (pdwCodePages
) *pdwCodePages
= 0;
1946 if (pcchCodePages
) *pcchCodePages
= 0;
1948 if (!pszSrc
|| !cchSrc
|| cchSrc
< 0)
1949 return E_INVALIDARG
;
1951 for (i
= 0; i
< cchSrc
; i
++)
1956 ret
= fnIMLangFontLink_GetCharCodePages(iface
, pszSrc
[i
], &cp
);
1957 if (ret
!= S_OK
) return E_FAIL
;
1962 /* FIXME: not tested */
1963 if (dwPriorityCodePages
& cps
) break;
1966 if (pdwCodePages
) *pdwCodePages
= cps
;
1967 if (pcchCodePages
) *pcchCodePages
= min( i
+ 1, cchSrc
);
1971 static HRESULT WINAPI
fnIMLangFontLink_CodePageToCodePages(
1972 IMLangFontLink
* iface
,
1974 DWORD
* pdwCodePages
)
1976 MLang_impl
*This
= impl_from_IMLangFontLink( iface
);
1980 TRACE("(%p) Seeking %u\n",This
, uCodePage
);
1982 rc
= TranslateCharsetInfo((DWORD
*)(DWORD_PTR
)uCodePage
, &cs
, TCI_SRCCODEPAGE
);
1986 *pdwCodePages
= cs
.fs
.fsCsb
[0];
1987 TRACE("resulting CodePages 0x%x\n",*pdwCodePages
);
1991 TRACE("CodePage Not Found\n");
1996 static HRESULT WINAPI
fnIMLangFontLink_CodePagesToCodePage(
1997 IMLangFontLink
* iface
,
1999 UINT uDefaultCodePage
,
2002 MLang_impl
*This
= impl_from_IMLangFontLink( iface
);
2003 DWORD mask
= 0x00000000;
2008 TRACE("(%p) scanning 0x%x default page %u\n",This
, dwCodePages
,
2011 *puCodePage
= 0x00000000;
2013 rc
= TranslateCharsetInfo((DWORD
*)(DWORD_PTR
)uDefaultCodePage
, &cs
,
2016 if (rc
&& (dwCodePages
& cs
.fs
.fsCsb
[0]))
2018 TRACE("Found Default Codepage\n");
2019 *puCodePage
= uDefaultCodePage
;
2024 for (i
= 0; i
< 32; i
++)
2028 if (dwCodePages
& mask
)
2033 rc
= TranslateCharsetInfo(Csb
, &cs
, TCI_SRCFONTSIG
);
2037 TRACE("Falling back to least significant found CodePage %u\n",
2039 *puCodePage
= cs
.ciACP
;
2044 TRACE("no codepage found\n");
2048 static HRESULT WINAPI
fnIMLangFontLink_GetFontCodePages(
2049 IMLangFontLink
* iface
,
2052 DWORD
* pdwCodePages
)
2055 FONTSIGNATURE fontsig
;
2056 MLang_impl
*This
= impl_from_IMLangFontLink( iface
);
2058 TRACE("(%p)\n",This
);
2060 old_font
= SelectObject(hDC
,hFont
);
2061 GetTextCharsetInfo(hDC
,&fontsig
, 0);
2062 SelectObject(hDC
,old_font
);
2064 *pdwCodePages
= fontsig
.fsCsb
[0];
2065 TRACE("CodePages is 0x%x\n",fontsig
.fsCsb
[0]);
2070 static HRESULT WINAPI
fnIMLangFontLink_MapFont(
2071 IMLangFontLink
* iface
,
2081 static HRESULT WINAPI
fnIMLangFontLink_ReleaseFont(
2082 IMLangFontLink
* iface
,
2089 static HRESULT WINAPI
fnIMLangFontLink_ResetFontMapping(
2090 IMLangFontLink
* iface
)
2097 static const IMLangFontLinkVtbl IMLangFontLink_vtbl
=
2099 fnIMLangFontLink_QueryInterface
,
2100 fnIMLangFontLink_AddRef
,
2101 fnIMLangFontLink_Release
,
2102 fnIMLangFontLink_GetCharCodePages
,
2103 fnIMLangFontLink_GetStrCodePages
,
2104 fnIMLangFontLink_CodePageToCodePages
,
2105 fnIMLangFontLink_CodePagesToCodePage
,
2106 fnIMLangFontLink_GetFontCodePages
,
2107 fnIMLangFontLink_MapFont
,
2108 fnIMLangFontLink_ReleaseFont
,
2109 fnIMLangFontLink_ResetFontMapping
,
2112 /******************************************************************************/
2114 static inline MLang_impl
*impl_from_IMultiLanguage( IMultiLanguage
*iface
)
2116 return CONTAINING_RECORD( iface
, MLang_impl
, vtbl_IMultiLanguage
);
2119 static HRESULT WINAPI
fnIMultiLanguage_QueryInterface(
2120 IMultiLanguage
* iface
,
2124 MLang_impl
*This
= impl_from_IMultiLanguage( iface
);
2125 return MLang_QueryInterface( This
, riid
, ppvObject
);
2128 static ULONG WINAPI
fnIMultiLanguage_AddRef( IMultiLanguage
* iface
)
2130 MLang_impl
*This
= impl_from_IMultiLanguage( iface
);
2131 return IMLangFontLink_AddRef( ((IMLangFontLink
*)This
) );
2134 static ULONG WINAPI
fnIMultiLanguage_Release( IMultiLanguage
* iface
)
2136 MLang_impl
*This
= impl_from_IMultiLanguage( iface
);
2137 return IMLangFontLink_Release( ((IMLangFontLink
*)This
) );
2140 static HRESULT WINAPI
fnIMultiLanguage_GetNumberOfCodePageInfo(
2141 IMultiLanguage
* iface
,
2144 MLang_impl
*This
= impl_from_IMultiLanguage( iface
);
2146 TRACE("(%p, %p)\n", This
, pcCodePage
);
2148 if (!pcCodePage
) return E_INVALIDARG
;
2150 *pcCodePage
= This
->total_cp
;
2154 static HRESULT WINAPI
fnIMultiLanguage_GetCodePageInfo(
2155 IMultiLanguage
* iface
,
2157 PMIMECPINFO pCodePageInfo
)
2160 MLang_impl
*This
= impl_from_IMultiLanguage( iface
);
2162 TRACE("%p, %u, %p\n", This
, uiCodePage
, pCodePageInfo
);
2164 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2166 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2168 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
2170 fill_cp_info(&mlang_data
[i
], n
, pCodePageInfo
);
2179 static HRESULT WINAPI
fnIMultiLanguage_GetFamilyCodePage(
2180 IMultiLanguage
* iface
,
2182 UINT
* puiFamilyCodePage
)
2184 return GetFamilyCodePage(uiCodePage
, puiFamilyCodePage
);
2187 static HRESULT WINAPI
fnIMultiLanguage_EnumCodePages(
2188 IMultiLanguage
* iface
,
2190 IEnumCodePage
** ppEnumCodePage
)
2192 MLang_impl
*This
= impl_from_IMultiLanguage( iface
);
2194 TRACE("%p %08x %p\n", This
, grfFlags
, ppEnumCodePage
);
2196 return EnumCodePage_create( This
, grfFlags
, 0, ppEnumCodePage
);
2199 static HRESULT WINAPI
fnIMultiLanguage_GetCharsetInfo(
2200 IMultiLanguage
* iface
,
2202 PMIMECSETINFO pCharsetInfo
)
2204 MLang_impl
*This
= impl_from_IMultiLanguage( iface
);
2205 return IMultiLanguage3_GetCharsetInfo((IMultiLanguage3
*)&This
->vtbl_IMultiLanguage3
, Charset
, pCharsetInfo
);
2208 static HRESULT WINAPI
fnIMultiLanguage_IsConvertible(
2209 IMultiLanguage
* iface
,
2210 DWORD dwSrcEncoding
,
2211 DWORD dwDstEncoding
)
2213 return IsConvertINetStringAvailable(dwSrcEncoding
, dwDstEncoding
);
2216 static HRESULT WINAPI
fnIMultiLanguage_ConvertString(
2217 IMultiLanguage
* iface
,
2219 DWORD dwSrcEncoding
,
2220 DWORD dwDstEncoding
,
2226 return ConvertINetString(pdwMode
, dwSrcEncoding
, dwDstEncoding
,
2227 (LPCSTR
)pSrcStr
, (LPINT
)pcSrcSize
, (LPSTR
)pDstStr
, (LPINT
)pcDstSize
);
2230 static HRESULT WINAPI
fnIMultiLanguage_ConvertStringToUnicode(
2231 IMultiLanguage
* iface
,
2239 return ConvertINetMultiByteToUnicode(pdwMode
, dwEncoding
,
2240 (LPCSTR
)pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2243 static HRESULT WINAPI
fnIMultiLanguage_ConvertStringFromUnicode(
2244 IMultiLanguage
* iface
,
2252 return ConvertINetUnicodeToMultiByte(pdwMode
, dwEncoding
,
2253 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2256 static HRESULT WINAPI
fnIMultiLanguage_ConvertStringReset(
2257 IMultiLanguage
* iface
)
2263 static HRESULT WINAPI
fnIMultiLanguage_GetRfc1766FromLcid(
2264 IMultiLanguage
* iface
,
2268 WCHAR buf
[MAX_RFC1766_NAME
];
2270 TRACE("%p %04x %p\n", iface
, lcid
, pbstrRfc1766
);
2272 return E_INVALIDARG
;
2274 if (!lcid_to_rfc1766W( lcid
, buf
, MAX_RFC1766_NAME
))
2276 *pbstrRfc1766
= SysAllocString( buf
);
2282 static HRESULT WINAPI
fnIMultiLanguage_GetLcidFromRfc1766(
2283 IMultiLanguage
* iface
,
2288 IEnumRfc1766
*rfc1766
;
2290 TRACE("%p %p %s\n", iface
, pLocale
, debugstr_w(bstrRfc1766
));
2292 if (!pLocale
|| !bstrRfc1766
)
2293 return E_INVALIDARG
;
2295 hr
= IMultiLanguage_EnumRfc1766(iface
, &rfc1766
);
2299 hr
= lcid_from_rfc1766(rfc1766
, pLocale
, bstrRfc1766
);
2301 IEnumRfc1766_Release(rfc1766
);
2305 /******************************************************************************/
2307 typedef struct tagEnumRfc1766_impl
2309 const IEnumRfc1766Vtbl
*vtbl_IEnumRfc1766
;
2315 static inline EnumRfc1766_impl
*impl_from_IEnumRfc1766( IEnumRfc1766
*iface
)
2317 return CONTAINING_RECORD( iface
, EnumRfc1766_impl
, vtbl_IEnumRfc1766
);
2320 static HRESULT WINAPI
fnIEnumRfc1766_QueryInterface(
2321 IEnumRfc1766
*iface
,
2325 EnumRfc1766_impl
*This
= impl_from_IEnumRfc1766( iface
);
2327 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
2329 if (IsEqualGUID(riid
, &IID_IUnknown
)
2330 || IsEqualGUID(riid
, &IID_IEnumRfc1766
))
2332 IEnumRfc1766_AddRef(iface
);
2333 TRACE("Returning IID_IEnumRfc1766 %p ref = %d\n", This
, This
->ref
);
2334 *ppvObject
= &(This
->vtbl_IEnumRfc1766
);
2338 WARN("(%p) -> (%s,%p), not found\n",This
,debugstr_guid(riid
),ppvObject
);
2339 return E_NOINTERFACE
;
2342 static ULONG WINAPI
fnIEnumRfc1766_AddRef(
2343 IEnumRfc1766
*iface
)
2345 EnumRfc1766_impl
*This
= impl_from_IEnumRfc1766( iface
);
2346 return InterlockedIncrement(&This
->ref
);
2349 static ULONG WINAPI
fnIEnumRfc1766_Release(
2350 IEnumRfc1766
*iface
)
2352 EnumRfc1766_impl
*This
= impl_from_IEnumRfc1766( iface
);
2353 ULONG ref
= InterlockedDecrement(&This
->ref
);
2355 TRACE("%p ref = %d\n", This
, ref
);
2358 TRACE("Destroying %p\n", This
);
2359 HeapFree(GetProcessHeap(), 0, This
->info
);
2360 HeapFree(GetProcessHeap(), 0, This
);
2365 static HRESULT WINAPI
fnIEnumRfc1766_Clone(
2366 IEnumRfc1766
*iface
,
2367 IEnumRfc1766
**ppEnum
)
2369 EnumRfc1766_impl
*This
= impl_from_IEnumRfc1766( iface
);
2371 FIXME("%p %p\n", This
, ppEnum
);
2375 static HRESULT WINAPI
fnIEnumRfc1766_Next(
2376 IEnumRfc1766
*iface
,
2379 ULONG
*pceltFetched
)
2382 EnumRfc1766_impl
*This
= impl_from_IEnumRfc1766( iface
);
2384 TRACE("%p %u %p %p\n", This
, celt
, rgelt
, pceltFetched
);
2386 if (!pceltFetched
) return S_FALSE
;
2389 if (!rgelt
) return S_FALSE
;
2391 if (This
->pos
+ celt
> This
->total
)
2392 celt
= This
->total
- This
->pos
;
2394 if (!celt
) return S_FALSE
;
2396 memcpy(rgelt
, This
->info
+ This
->pos
, celt
* sizeof(RFC1766INFO
));
2397 *pceltFetched
= celt
;
2400 for (i
= 0; i
< celt
; i
++)
2402 TRACE("#%u: %08x %s %s\n",
2404 wine_dbgstr_w(rgelt
[i
].wszRfc1766
),
2405 wine_dbgstr_w(rgelt
[i
].wszLocaleName
));
2410 static HRESULT WINAPI
fnIEnumRfc1766_Reset(
2411 IEnumRfc1766
*iface
)
2413 EnumRfc1766_impl
*This
= impl_from_IEnumRfc1766( iface
);
2415 TRACE("%p\n", This
);
2421 static HRESULT WINAPI
fnIEnumRfc1766_Skip(
2422 IEnumRfc1766
*iface
,
2425 EnumRfc1766_impl
*This
= impl_from_IEnumRfc1766( iface
);
2427 TRACE("%p %u\n", This
, celt
);
2429 if (celt
>= This
->total
) return S_FALSE
;
2435 static const IEnumRfc1766Vtbl IEnumRfc1766_vtbl
=
2437 fnIEnumRfc1766_QueryInterface
,
2438 fnIEnumRfc1766_AddRef
,
2439 fnIEnumRfc1766_Release
,
2440 fnIEnumRfc1766_Clone
,
2441 fnIEnumRfc1766_Next
,
2442 fnIEnumRfc1766_Reset
,
2446 struct enum_locales_data
2449 DWORD total
, allocated
;
2452 static BOOL CALLBACK
enum_locales_proc(LPWSTR locale
)
2455 struct enum_locales_data
*data
= TlsGetValue(MLANG_tls_index
);
2458 TRACE("%s\n", debugstr_w(locale
));
2460 if (data
->total
>= data
->allocated
)
2462 data
->allocated
+= 32;
2463 data
->info
= HeapReAlloc(GetProcessHeap(), 0, data
->info
, data
->allocated
* sizeof(RFC1766INFO
));
2464 if (!data
->info
) return FALSE
;
2467 info
= &data
->info
[data
->total
];
2469 info
->lcid
= strtolW(locale
, &end
, 16);
2470 if (*end
) /* invalid number */
2473 info
->wszRfc1766
[0] = 0;
2474 lcid_to_rfc1766W( info
->lcid
, info
->wszRfc1766
, MAX_RFC1766_NAME
);
2476 info
->wszLocaleName
[0] = 0;
2477 GetLocaleInfoW(info
->lcid
, LOCALE_SLANGUAGE
, info
->wszLocaleName
, MAX_LOCALE_NAME
);
2478 TRACE("ISO639: %s SLANGUAGE: %s\n", wine_dbgstr_w(info
->wszRfc1766
), wine_dbgstr_w(info
->wszLocaleName
));
2485 static HRESULT
EnumRfc1766_create(LANGID LangId
, IEnumRfc1766
**ppEnum
)
2487 EnumRfc1766_impl
*rfc
;
2488 struct enum_locales_data data
;
2490 TRACE("%04x, %p\n", LangId
, ppEnum
);
2492 rfc
= HeapAlloc( GetProcessHeap(), 0, sizeof(EnumRfc1766_impl
) );
2493 rfc
->vtbl_IEnumRfc1766
= &IEnumRfc1766_vtbl
;
2499 data
.allocated
= 160;
2500 data
.info
= HeapAlloc(GetProcessHeap(), 0, data
.allocated
* sizeof(RFC1766INFO
));
2503 HeapFree(GetProcessHeap(), 0, rfc
);
2507 TlsSetValue(MLANG_tls_index
, &data
);
2508 EnumSystemLocalesW(enum_locales_proc
, 0/*LOCALE_SUPPORTED*/);
2509 TlsSetValue(MLANG_tls_index
, NULL
);
2511 TRACE("enumerated %d rfc1766 structures\n", data
.total
);
2515 HeapFree(GetProcessHeap(), 0, data
.info
);
2516 HeapFree(GetProcessHeap(), 0, rfc
);
2520 rfc
->info
= data
.info
;
2521 rfc
->total
= data
.total
;
2523 *ppEnum
= (IEnumRfc1766
*)rfc
;
2527 static HRESULT WINAPI
fnIMultiLanguage_EnumRfc1766(
2528 IMultiLanguage
*iface
,
2529 IEnumRfc1766
**ppEnumRfc1766
)
2531 MLang_impl
*This
= impl_from_IMultiLanguage( iface
);
2533 TRACE("%p %p\n", This
, ppEnumRfc1766
);
2535 return EnumRfc1766_create(0, ppEnumRfc1766
);
2538 /******************************************************************************/
2540 static HRESULT WINAPI
fnIMultiLanguage_GetRfc1766Info(
2541 IMultiLanguage
* iface
,
2543 PRFC1766INFO pRfc1766Info
)
2545 LCTYPE type
= LOCALE_SLANGUAGE
;
2547 TRACE("(%p, 0x%04x, %p)\n", iface
, Locale
, pRfc1766Info
);
2550 return E_INVALIDARG
;
2552 if ((PRIMARYLANGID(Locale
) == LANG_ENGLISH
) ||
2553 (PRIMARYLANGID(Locale
) == LANG_CHINESE
) ||
2554 (PRIMARYLANGID(Locale
) == LANG_ARABIC
)) {
2556 if (!SUBLANGID(Locale
))
2557 type
= LOCALE_SENGLANGUAGE
; /* suppress country */
2561 if (!SUBLANGID(Locale
)) {
2562 TRACE("SUBLANGID missing in 0x%04x\n", Locale
);
2567 pRfc1766Info
->lcid
= Locale
;
2568 pRfc1766Info
->wszRfc1766
[0] = 0;
2569 pRfc1766Info
->wszLocaleName
[0] = 0;
2571 if ((!lcid_to_rfc1766W(Locale
, pRfc1766Info
->wszRfc1766
, MAX_RFC1766_NAME
)) &&
2572 (GetLocaleInfoW(Locale
, type
, pRfc1766Info
->wszLocaleName
, MAX_LOCALE_NAME
) > 0))
2575 /* Locale not supported */
2576 return E_INVALIDARG
;
2579 static HRESULT WINAPI
fnIMultiLanguage_CreateConvertCharset(
2580 IMultiLanguage
* iface
,
2584 IMLangConvertCharset
** ppMLangConvertCharset
)
2590 static const IMultiLanguageVtbl IMultiLanguage_vtbl
=
2592 fnIMultiLanguage_QueryInterface
,
2593 fnIMultiLanguage_AddRef
,
2594 fnIMultiLanguage_Release
,
2595 fnIMultiLanguage_GetNumberOfCodePageInfo
,
2596 fnIMultiLanguage_GetCodePageInfo
,
2597 fnIMultiLanguage_GetFamilyCodePage
,
2598 fnIMultiLanguage_EnumCodePages
,
2599 fnIMultiLanguage_GetCharsetInfo
,
2600 fnIMultiLanguage_IsConvertible
,
2601 fnIMultiLanguage_ConvertString
,
2602 fnIMultiLanguage_ConvertStringToUnicode
,
2603 fnIMultiLanguage_ConvertStringFromUnicode
,
2604 fnIMultiLanguage_ConvertStringReset
,
2605 fnIMultiLanguage_GetRfc1766FromLcid
,
2606 fnIMultiLanguage_GetLcidFromRfc1766
,
2607 fnIMultiLanguage_EnumRfc1766
,
2608 fnIMultiLanguage_GetRfc1766Info
,
2609 fnIMultiLanguage_CreateConvertCharset
,
2613 /******************************************************************************/
2615 static inline MLang_impl
*impl_from_IMultiLanguage3( IMultiLanguage3
*iface
)
2617 return CONTAINING_RECORD( iface
, MLang_impl
, vtbl_IMultiLanguage3
);
2620 static HRESULT WINAPI
fnIMultiLanguage2_QueryInterface(
2621 IMultiLanguage3
* iface
,
2625 MLang_impl
*This
= impl_from_IMultiLanguage3( iface
);
2626 return MLang_QueryInterface( This
, riid
, ppvObject
);
2629 static ULONG WINAPI
fnIMultiLanguage2_AddRef( IMultiLanguage3
* iface
)
2631 MLang_impl
*This
= impl_from_IMultiLanguage3( iface
);
2632 return MLang_AddRef( This
);
2635 static ULONG WINAPI
fnIMultiLanguage2_Release( IMultiLanguage3
* iface
)
2637 MLang_impl
*This
= impl_from_IMultiLanguage3( iface
);
2638 return MLang_Release( This
);
2641 static HRESULT WINAPI
fnIMultiLanguage2_GetNumberOfCodePageInfo(
2642 IMultiLanguage3
* iface
,
2645 MLang_impl
*This
= impl_from_IMultiLanguage3( iface
);
2647 TRACE("%p, %p\n", This
, pcCodePage
);
2649 if (!pcCodePage
) return E_INVALIDARG
;
2651 *pcCodePage
= This
->total_cp
;
2655 static void fill_cp_info(const struct mlang_data
*ml_data
, UINT index
, MIMECPINFO
*mime_cp_info
)
2659 if (TranslateCharsetInfo((DWORD
*)(DWORD_PTR
)ml_data
->family_codepage
, &csi
,
2661 mime_cp_info
->bGDICharset
= csi
.ciCharset
;
2663 mime_cp_info
->bGDICharset
= DEFAULT_CHARSET
;
2665 mime_cp_info
->dwFlags
= ml_data
->mime_cp_info
[index
].flags
;
2666 mime_cp_info
->uiCodePage
= ml_data
->mime_cp_info
[index
].cp
;
2667 mime_cp_info
->uiFamilyCodePage
= ml_data
->family_codepage
;
2668 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].description
, -1,
2669 mime_cp_info
->wszDescription
, sizeof(mime_cp_info
->wszDescription
)/sizeof(WCHAR
));
2670 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].web_charset
, -1,
2671 mime_cp_info
->wszWebCharset
, sizeof(mime_cp_info
->wszWebCharset
)/sizeof(WCHAR
));
2672 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].header_charset
, -1,
2673 mime_cp_info
->wszHeaderCharset
, sizeof(mime_cp_info
->wszHeaderCharset
)/sizeof(WCHAR
));
2674 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].body_charset
, -1,
2675 mime_cp_info
->wszBodyCharset
, sizeof(mime_cp_info
->wszBodyCharset
)/sizeof(WCHAR
));
2677 MultiByteToWideChar(CP_ACP
, 0, ml_data
->fixed_font
, -1,
2678 mime_cp_info
->wszFixedWidthFont
, sizeof(mime_cp_info
->wszFixedWidthFont
)/sizeof(WCHAR
));
2679 MultiByteToWideChar(CP_ACP
, 0, ml_data
->proportional_font
, -1,
2680 mime_cp_info
->wszProportionalFont
, sizeof(mime_cp_info
->wszProportionalFont
)/sizeof(WCHAR
));
2682 TRACE("%08x %u %u %s %s %s %s %s %s %d\n",
2683 mime_cp_info
->dwFlags
, mime_cp_info
->uiCodePage
,
2684 mime_cp_info
->uiFamilyCodePage
,
2685 wine_dbgstr_w(mime_cp_info
->wszDescription
),
2686 wine_dbgstr_w(mime_cp_info
->wszWebCharset
),
2687 wine_dbgstr_w(mime_cp_info
->wszHeaderCharset
),
2688 wine_dbgstr_w(mime_cp_info
->wszBodyCharset
),
2689 wine_dbgstr_w(mime_cp_info
->wszFixedWidthFont
),
2690 wine_dbgstr_w(mime_cp_info
->wszProportionalFont
),
2691 mime_cp_info
->bGDICharset
);
2694 static HRESULT WINAPI
fnIMultiLanguage2_GetCodePageInfo(
2695 IMultiLanguage3
* iface
,
2698 PMIMECPINFO pCodePageInfo
)
2701 MLang_impl
*This
= impl_from_IMultiLanguage3( iface
);
2703 TRACE("%p, %u, %04x, %p\n", This
, uiCodePage
, LangId
, pCodePageInfo
);
2705 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2707 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2709 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
2711 fill_cp_info(&mlang_data
[i
], n
, pCodePageInfo
);
2720 static HRESULT WINAPI
fnIMultiLanguage2_GetFamilyCodePage(
2721 IMultiLanguage3
* iface
,
2723 UINT
* puiFamilyCodePage
)
2725 return GetFamilyCodePage(uiCodePage
, puiFamilyCodePage
);
2728 static HRESULT WINAPI
fnIMultiLanguage2_EnumCodePages(
2729 IMultiLanguage3
* iface
,
2732 IEnumCodePage
** ppEnumCodePage
)
2734 MLang_impl
*This
= impl_from_IMultiLanguage3( iface
);
2736 TRACE("%p %08x %04x %p\n", This
, grfFlags
, LangId
, ppEnumCodePage
);
2738 return EnumCodePage_create( This
, grfFlags
, LangId
, ppEnumCodePage
);
2741 static HRESULT WINAPI
fnIMultiLanguage2_GetCharsetInfo(
2742 IMultiLanguage3
* iface
,
2744 PMIMECSETINFO pCharsetInfo
)
2747 MLang_impl
*This
= impl_from_IMultiLanguage3( iface
);
2749 TRACE("%p %s %p\n", This
, debugstr_w(Charset
), pCharsetInfo
);
2751 if (!pCharsetInfo
) return E_FAIL
;
2753 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2755 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2757 WCHAR csetW
[MAX_MIMECSET_NAME
];
2759 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].mime_cp_info
[n
].web_charset
, -1, csetW
, MAX_MIMECSET_NAME
);
2760 if (!lstrcmpiW(Charset
, csetW
))
2762 pCharsetInfo
->uiCodePage
= mlang_data
[i
].family_codepage
;
2763 pCharsetInfo
->uiInternetEncoding
= mlang_data
[i
].mime_cp_info
[n
].cp
;
2764 strcpyW(pCharsetInfo
->wszCharset
, csetW
);
2771 * Since we do not support charsets like iso-2022-jp and do not have
2772 * them in our database as a primary (web_charset) encoding this loop
2773 * does an attempt to 'approximate' charset name by header_charset.
2775 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2777 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2779 WCHAR csetW
[MAX_MIMECSET_NAME
];
2781 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].mime_cp_info
[n
].header_charset
, -1, csetW
, MAX_MIMECSET_NAME
);
2782 if (!lstrcmpiW(Charset
, csetW
))
2784 pCharsetInfo
->uiCodePage
= mlang_data
[i
].family_codepage
;
2785 pCharsetInfo
->uiInternetEncoding
= mlang_data
[i
].mime_cp_info
[n
].cp
;
2786 strcpyW(pCharsetInfo
->wszCharset
, csetW
);
2795 static HRESULT WINAPI
fnIMultiLanguage2_IsConvertible(
2796 IMultiLanguage3
* iface
,
2797 DWORD dwSrcEncoding
,
2798 DWORD dwDstEncoding
)
2800 return IsConvertINetStringAvailable(dwSrcEncoding
, dwDstEncoding
);
2803 static HRESULT WINAPI
fnIMultiLanguage2_ConvertString(
2804 IMultiLanguage3
* iface
,
2806 DWORD dwSrcEncoding
,
2807 DWORD dwDstEncoding
,
2813 return ConvertINetString(pdwMode
, dwSrcEncoding
, dwDstEncoding
,
2814 (LPCSTR
)pSrcStr
, (LPINT
)pcSrcSize
, (LPSTR
)pDstStr
, (LPINT
)pcDstSize
);
2817 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringToUnicode(
2818 IMultiLanguage3
* iface
,
2826 return ConvertINetMultiByteToUnicode(pdwMode
, dwEncoding
,
2827 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2830 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringFromUnicode(
2831 IMultiLanguage3
* iface
,
2839 return ConvertINetUnicodeToMultiByte(pdwMode
, dwEncoding
,
2840 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2843 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringReset(
2844 IMultiLanguage3
* iface
)
2850 static HRESULT WINAPI
fnIMultiLanguage2_GetRfc1766FromLcid(
2851 IMultiLanguage3
* iface
,
2855 WCHAR buf
[MAX_RFC1766_NAME
];
2857 TRACE("%p %04x %p\n", iface
, lcid
, pbstrRfc1766
);
2859 return E_INVALIDARG
;
2861 if (!lcid_to_rfc1766W( lcid
, buf
, MAX_RFC1766_NAME
))
2863 *pbstrRfc1766
= SysAllocString( buf
);
2869 static HRESULT WINAPI
fnIMultiLanguage2_GetLcidFromRfc1766(
2870 IMultiLanguage3
* iface
,
2875 IEnumRfc1766
*rfc1766
;
2877 TRACE("%p %p %s\n", iface
, pLocale
, debugstr_w(bstrRfc1766
));
2879 if (!pLocale
|| !bstrRfc1766
)
2880 return E_INVALIDARG
;
2882 hr
= IMultiLanguage2_EnumRfc1766(iface
, 0, &rfc1766
);
2886 hr
= lcid_from_rfc1766(rfc1766
, pLocale
, bstrRfc1766
);
2888 IEnumRfc1766_Release(rfc1766
);
2892 static HRESULT WINAPI
fnIMultiLanguage2_EnumRfc1766(
2893 IMultiLanguage3
* iface
,
2895 IEnumRfc1766
** ppEnumRfc1766
)
2897 MLang_impl
*This
= impl_from_IMultiLanguage3( iface
);
2899 TRACE("%p %p\n", This
, ppEnumRfc1766
);
2901 return EnumRfc1766_create(LangId
, ppEnumRfc1766
);
2904 static HRESULT WINAPI
fnIMultiLanguage2_GetRfc1766Info(
2905 IMultiLanguage3
* iface
,
2908 PRFC1766INFO pRfc1766Info
)
2910 static LANGID last_lang
= -1;
2911 LCTYPE type
= LOCALE_SLANGUAGE
;
2913 TRACE("(%p, 0x%04x, 0x%04x, %p)\n", iface
, Locale
, LangId
, pRfc1766Info
);
2916 return E_INVALIDARG
;
2918 if ((PRIMARYLANGID(Locale
) == LANG_ENGLISH
) ||
2919 (PRIMARYLANGID(Locale
) == LANG_CHINESE
) ||
2920 (PRIMARYLANGID(Locale
) == LANG_ARABIC
)) {
2922 if (!SUBLANGID(Locale
))
2923 type
= LOCALE_SENGLANGUAGE
; /* suppress country */
2927 if (!SUBLANGID(Locale
)) {
2928 TRACE("SUBLANGID missing in 0x%04x\n", Locale
);
2933 pRfc1766Info
->lcid
= Locale
;
2934 pRfc1766Info
->wszRfc1766
[0] = 0;
2935 pRfc1766Info
->wszLocaleName
[0] = 0;
2937 if ((PRIMARYLANGID(LangId
) != LANG_ENGLISH
) &&
2938 (last_lang
!= LangId
)) {
2939 FIXME("Only english names supported (requested: 0x%04x)\n", LangId
);
2943 if ((!lcid_to_rfc1766W(Locale
, pRfc1766Info
->wszRfc1766
, MAX_RFC1766_NAME
)) &&
2944 (GetLocaleInfoW(Locale
, type
, pRfc1766Info
->wszLocaleName
, MAX_LOCALE_NAME
) > 0))
2947 /* Locale not supported */
2948 return E_INVALIDARG
;
2951 static HRESULT WINAPI
fnIMultiLanguage2_CreateConvertCharset(
2952 IMultiLanguage3
* iface
,
2956 IMLangConvertCharset
** ppMLangConvertCharset
)
2962 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringInIStream(
2963 IMultiLanguage3
* iface
,
2967 DWORD dwSrcEncoding
,
2968 DWORD dwDstEncoding
,
2972 char *src
, *dst
= NULL
;
2977 TRACE("%p %0x8 %s %u %u %p %p\n",
2978 pdwMode
, dwFlag
, debugstr_w(lpFallBack
), dwSrcEncoding
, dwDstEncoding
, pstmIn
, pstmOut
);
2980 FIXME("dwFlag and lpFallBack not handled\n");
2982 hr
= IStream_Stat(pstmIn
, &stat
, STATFLAG_NONAME
);
2983 if (FAILED(hr
)) return hr
;
2985 if (stat
.cbSize
.QuadPart
> MAXLONG
) return E_INVALIDARG
;
2986 if (!(src
= HeapAlloc(GetProcessHeap(), 0, stat
.cbSize
.QuadPart
))) return E_OUTOFMEMORY
;
2988 hr
= IStream_Read(pstmIn
, src
, stat
.cbSize
.QuadPart
, (ULONG
*)&srclen
);
2989 if (FAILED(hr
)) goto exit
;
2991 hr
= ConvertINetString(pdwMode
, dwSrcEncoding
, dwDstEncoding
, src
, &srclen
, NULL
, &dstlen
);
2992 if (FAILED(hr
)) goto exit
;
2994 if (!(dst
= HeapAlloc(GetProcessHeap(), 0, dstlen
)))
2999 hr
= ConvertINetString(pdwMode
, dwSrcEncoding
, dwDstEncoding
, src
, &srclen
, dst
, &dstlen
);
3000 if (FAILED(hr
)) goto exit
;
3002 hr
= IStream_Write(pstmOut
, dst
, dstlen
, NULL
);
3005 HeapFree(GetProcessHeap(), 0, src
);
3006 HeapFree(GetProcessHeap(), 0, dst
);
3011 * TODO: handle dwFlag and lpFallBack
3013 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringToUnicodeEx(
3014 IMultiLanguage3
* iface
,
3025 return ConvertINetMultiByteToUnicode(pdwMode
, dwEncoding
,
3026 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
3029 /*****************************************************************************
3030 * MultiLanguage2::ConvertStringToUnicodeEx
3032 * Translates the multibyte string from the specified code page to Unicode.
3035 * see ConvertStringToUnicode
3037 * lpFallBack if dwFlag contains MLCONVCHARF_USEDEFCHAR, lpFallBack string used
3038 * instead unconvertible characters.
3042 * S_FALSE The conversion is not supported.
3043 * E_FAIL Some error has occurred.
3045 * TODO: handle dwFlag and lpFallBack
3047 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringFromUnicodeEx(
3048 IMultiLanguage3
* This
,
3059 return ConvertINetUnicodeToMultiByte(pdwMode
, dwEncoding
,
3060 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
3063 static HRESULT WINAPI
fnIMultiLanguage2_DetectCodepageInIStream(
3064 IMultiLanguage3
* iface
,
3066 DWORD dwPrefWinCodePage
,
3068 DetectEncodingInfo
* lpEncoding
,
3075 static HRESULT WINAPI
fnIMultiLanguage2_DetectInputCodepage(
3076 IMultiLanguage3
* iface
,
3078 DWORD dwPrefWinCodePage
,
3081 DetectEncodingInfo
* lpEncoding
,
3088 static HRESULT WINAPI
fnIMultiLanguage2_ValidateCodePage(
3089 IMultiLanguage3
* iface
,
3093 return IMultiLanguage2_ValidateCodePageEx(iface
,uiCodePage
,hwnd
,0);
3096 static HRESULT WINAPI
fnIMultiLanguage2_GetCodePageDescription(
3097 IMultiLanguage3
* iface
,
3100 LPWSTR lpWideCharStr
,
3103 /* Find first instance */
3106 TRACE ("%u, %04x, %p, %d\n", uiCodePage
, lcid
, lpWideCharStr
, cchWideChar
);
3107 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
3109 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
3111 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
3113 MultiByteToWideChar(CP_ACP
, 0,
3114 mlang_data
[i
].mime_cp_info
[n
].description
,
3115 -1, lpWideCharStr
, cchWideChar
);
3124 static HRESULT WINAPI
fnIMultiLanguage2_IsCodePageInstallable(
3125 IMultiLanguage3
* iface
,
3128 FIXME("%u\n", uiCodePage
);
3132 static HRESULT WINAPI
fnIMultiLanguage2_SetMimeDBSource(
3133 IMultiLanguage3
* iface
,
3136 FIXME("0x%08x\n", dwSource
);
3140 static HRESULT WINAPI
fnIMultiLanguage2_GetNumberOfScripts(
3141 IMultiLanguage3
* iface
,
3144 MLang_impl
*This
= impl_from_IMultiLanguage3( iface
);
3146 TRACE("%p %p\n", This
, pnScripts
);
3148 if (!pnScripts
) return S_FALSE
;
3150 *pnScripts
= This
->total_scripts
;
3154 static HRESULT WINAPI
fnIMultiLanguage2_EnumScripts(
3155 IMultiLanguage3
* iface
,
3158 IEnumScript
** ppEnumScript
)
3160 MLang_impl
*This
= impl_from_IMultiLanguage3( iface
);
3162 TRACE("%p %08x %04x %p\n", This
, dwFlags
, LangId
, ppEnumScript
);
3164 return EnumScript_create( This
, dwFlags
, LangId
, ppEnumScript
);
3167 static HRESULT WINAPI
fnIMultiLanguage2_ValidateCodePageEx(
3168 IMultiLanguage3
* iface
,
3171 DWORD dwfIODControl
)
3174 MLang_impl
*This
= impl_from_IMultiLanguage3( iface
);
3176 TRACE("%p %u %p %08x\n", This
, uiCodePage
, hwnd
, dwfIODControl
);
3178 /* quick check for kernel32 supported code pages */
3179 if (IsValidCodePage(uiCodePage
))
3182 /* check for mlang supported code pages */
3183 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
3186 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
3188 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
3193 if (dwfIODControl
!= CPIOD_PEEK
)
3194 FIXME("Request to install codepage language pack not handled\n");
3199 static HRESULT WINAPI
fnIMultiLanguage3_DetectOutboundCodePage(
3200 IMultiLanguage3
*iface
,
3202 LPCWSTR lpWideCharStr
,
3204 UINT
*puiPreferredCodePages
,
3205 UINT nPreferredCodePages
,
3206 UINT
*puiDetectedCodePages
,
3207 UINT
*pnDetectedCodePages
,
3208 WCHAR
*lpSpecialChar
)
3210 MLang_impl
*This
= impl_from_IMultiLanguage3( iface
);
3212 FIXME("(%p)->(%08x %s %u %p %u %p %p %p)\n", This
, dwFlags
, debugstr_w(lpWideCharStr
),
3213 cchWideChar
, puiPreferredCodePages
, nPreferredCodePages
, puiDetectedCodePages
,
3214 pnDetectedCodePages
, lpSpecialChar
);
3218 static HRESULT WINAPI
fnIMultiLanguage3_DetectOutboundCodePageInIStream(
3219 IMultiLanguage3
*iface
,
3222 UINT
*puiPreferredCodePages
,
3223 UINT nPreferredCodePages
,
3224 UINT
*puiDetectedCodePages
,
3225 UINT
*pnDetectedCodePages
,
3226 WCHAR
*lpSpecialChar
)
3228 MLang_impl
*This
= impl_from_IMultiLanguage3( iface
);
3230 FIXME("(%p)->(%08x %p %p %u %p %p %p)\n", This
, dwFlags
, pStrIn
,
3231 puiPreferredCodePages
, nPreferredCodePages
, puiDetectedCodePages
,
3232 pnDetectedCodePages
, lpSpecialChar
);
3236 static const IMultiLanguage3Vtbl IMultiLanguage3_vtbl
=
3238 fnIMultiLanguage2_QueryInterface
,
3239 fnIMultiLanguage2_AddRef
,
3240 fnIMultiLanguage2_Release
,
3241 fnIMultiLanguage2_GetNumberOfCodePageInfo
,
3242 fnIMultiLanguage2_GetCodePageInfo
,
3243 fnIMultiLanguage2_GetFamilyCodePage
,
3244 fnIMultiLanguage2_EnumCodePages
,
3245 fnIMultiLanguage2_GetCharsetInfo
,
3246 fnIMultiLanguage2_IsConvertible
,
3247 fnIMultiLanguage2_ConvertString
,
3248 fnIMultiLanguage2_ConvertStringToUnicode
,
3249 fnIMultiLanguage2_ConvertStringFromUnicode
,
3250 fnIMultiLanguage2_ConvertStringReset
,
3251 fnIMultiLanguage2_GetRfc1766FromLcid
,
3252 fnIMultiLanguage2_GetLcidFromRfc1766
,
3253 fnIMultiLanguage2_EnumRfc1766
,
3254 fnIMultiLanguage2_GetRfc1766Info
,
3255 fnIMultiLanguage2_CreateConvertCharset
,
3256 fnIMultiLanguage2_ConvertStringInIStream
,
3257 fnIMultiLanguage2_ConvertStringToUnicodeEx
,
3258 fnIMultiLanguage2_ConvertStringFromUnicodeEx
,
3259 fnIMultiLanguage2_DetectCodepageInIStream
,
3260 fnIMultiLanguage2_DetectInputCodepage
,
3261 fnIMultiLanguage2_ValidateCodePage
,
3262 fnIMultiLanguage2_GetCodePageDescription
,
3263 fnIMultiLanguage2_IsCodePageInstallable
,
3264 fnIMultiLanguage2_SetMimeDBSource
,
3265 fnIMultiLanguage2_GetNumberOfScripts
,
3266 fnIMultiLanguage2_EnumScripts
,
3267 fnIMultiLanguage2_ValidateCodePageEx
,
3268 fnIMultiLanguage3_DetectOutboundCodePage
,
3269 fnIMultiLanguage3_DetectOutboundCodePageInIStream
3272 /******************************************************************************/
3274 static inline MLang_impl
*impl_from_IMLangFontLink2( IMLangFontLink2
*iface
)
3276 return CONTAINING_RECORD( iface
, MLang_impl
, vtbl_IMLangFontLink2
);
3279 static HRESULT WINAPI
fnIMLangFontLink2_QueryInterface(
3280 IMLangFontLink2
* iface
,
3284 MLang_impl
*This
= impl_from_IMLangFontLink2( iface
);
3285 return MLang_QueryInterface( This
, riid
, ppvObject
);
3288 static ULONG WINAPI
fnIMLangFontLink2_AddRef( IMLangFontLink2
* iface
)
3290 MLang_impl
*This
= impl_from_IMLangFontLink2( iface
);
3291 return MLang_AddRef( This
);
3294 static ULONG WINAPI
fnIMLangFontLink2_Release( IMLangFontLink2
* iface
)
3296 MLang_impl
*This
= impl_from_IMLangFontLink2( iface
);
3297 return MLang_Release( This
);
3300 static HRESULT WINAPI
fnIMLangFontLink2_GetCharCodePages( IMLangFontLink2
* This
,
3301 WCHAR chSrc
, DWORD
*pdwCodePages
)
3303 FIXME("(%p)->%s %p\n",This
, debugstr_wn(&chSrc
,1),pdwCodePages
);
3307 static HRESULT WINAPI
fnIMLangFontLink2_GetStrCodePages( IMLangFontLink2
* This
,
3308 const WCHAR
*pszSrc
, LONG cchSrc
, DWORD dwPriorityCodePages
,
3309 DWORD
*pdwCodePages
, LONG
*pcchCodePages
)
3311 return fnIMLangFontLink_GetStrCodePages((IMLangFontLink
*)This
,
3312 pszSrc
, cchSrc
, dwPriorityCodePages
, pdwCodePages
, pcchCodePages
);
3315 static HRESULT WINAPI
fnIMLangFontLink2_CodePageToCodePages(IMLangFontLink2
* This
,
3317 DWORD
*pdwCodePages
)
3319 FIXME("(%p)->%i %p\n",This
, uCodePage
, pdwCodePages
);
3323 static HRESULT WINAPI
fnIMLangFontLink2_CodePagesToCodePage(IMLangFontLink2
* This
,
3324 DWORD dwCodePages
, UINT uDefaultCodePage
, UINT
*puCodePage
)
3326 FIXME("(%p)->%i %i %p\n",This
, dwCodePages
, uDefaultCodePage
, puCodePage
);
3330 static HRESULT WINAPI
fnIMLangFontLink2_GetFontCodePages(IMLangFontLink2
* This
,
3331 HDC hDC
, HFONT hFont
, DWORD
*pdwCodePages
)
3333 FIXME("(%p)->%p %p %p\n",This
, hDC
, hFont
, pdwCodePages
);
3337 static HRESULT WINAPI
fnIMLangFontLink2_ReleaseFont(IMLangFontLink2
* This
,
3340 FIXME("(%p)->%p\n",This
, hFont
);
3344 static HRESULT WINAPI
fnIMLangFontLink2_ResetFontMapping(IMLangFontLink2
* This
)
3346 FIXME("(%p)->\n",This
);
3350 static HRESULT WINAPI
fnIMLangFontLink2_MapFont(IMLangFontLink2
* This
,
3351 HDC hDC
, DWORD dwCodePages
, WCHAR chSrc
, HFONT
*pFont
)
3353 FIXME("(%p)->%p %i %s %p\n",This
, hDC
, dwCodePages
, debugstr_wn(&chSrc
,1), pFont
);
3357 static HRESULT WINAPI
fnIMLangFontLink2_GetFontUnicodeRanges(IMLangFontLink2
* This
,
3358 HDC hDC
, UINT
*puiRanges
, UNICODERANGE
*pUranges
)
3360 FIXME("(%p)->%p %p %p\n",This
, hDC
, puiRanges
, pUranges
);
3364 static HRESULT WINAPI
fnIMLangFontLink2_GetScriptFontInfo(IMLangFontLink2
* This
,
3365 SCRIPT_ID sid
, DWORD dwFlags
, UINT
*puiFonts
,
3366 SCRIPTFONTINFO
*pScriptFont
)
3370 TRACE("(%p)->%u %x %p %p\n", This
, sid
, dwFlags
, puiFonts
, pScriptFont
);
3372 if (!dwFlags
) dwFlags
= SCRIPTCONTF_PROPORTIONAL_FONT
;
3374 for (i
= 0, j
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
3376 if (sid
== mlang_data
[i
].sid
)
3380 if (j
>= *puiFonts
) break;
3382 pScriptFont
[j
].scripts
= 1 << mlang_data
[i
].sid
;
3383 if (dwFlags
== SCRIPTCONTF_FIXED_FONT
)
3385 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].fixed_font
, -1,
3386 pScriptFont
[j
].wszFont
, MAX_MIMEFACE_NAME
);
3388 else if (dwFlags
== SCRIPTCONTF_PROPORTIONAL_FONT
)
3390 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].proportional_font
, -1,
3391 pScriptFont
[j
].wszFont
, MAX_MIMEFACE_NAME
);
3401 static HRESULT WINAPI
fnIMLangFontLink2_CodePageToScriptID(IMLangFontLink2
* This
,
3402 UINT uiCodePage
, SCRIPT_ID
*pSid
)
3404 FIXME("(%p)->%i %p\n",This
, uiCodePage
, pSid
);
3408 static const IMLangFontLink2Vtbl IMLangFontLink2_vtbl
=
3410 fnIMLangFontLink2_QueryInterface
,
3411 fnIMLangFontLink2_AddRef
,
3412 fnIMLangFontLink2_Release
,
3413 fnIMLangFontLink2_GetCharCodePages
,
3414 fnIMLangFontLink2_GetStrCodePages
,
3415 fnIMLangFontLink2_CodePageToCodePages
,
3416 fnIMLangFontLink2_CodePagesToCodePage
,
3417 fnIMLangFontLink2_GetFontCodePages
,
3418 fnIMLangFontLink2_ReleaseFont
,
3419 fnIMLangFontLink2_ResetFontMapping
,
3420 fnIMLangFontLink2_MapFont
,
3421 fnIMLangFontLink2_GetFontUnicodeRanges
,
3422 fnIMLangFontLink2_GetScriptFontInfo
,
3423 fnIMLangFontLink2_CodePageToScriptID
3426 /******************************************************************************/
3428 static inline MLang_impl
*impl_from_IMLangLineBreakConsole( IMLangLineBreakConsole
*iface
)
3430 return CONTAINING_RECORD( iface
, MLang_impl
, vtbl_IMLangLineBreakConsole
);
3433 static HRESULT WINAPI
fnIMLangLineBreakConsole_QueryInterface(
3434 IMLangLineBreakConsole
* iface
,
3438 MLang_impl
*This
= impl_from_IMLangLineBreakConsole( iface
);
3439 return MLang_QueryInterface( This
, riid
, ppvObject
);
3442 static ULONG WINAPI
fnIMLangLineBreakConsole_AddRef(
3443 IMLangLineBreakConsole
* iface
)
3445 MLang_impl
*This
= impl_from_IMLangLineBreakConsole( iface
);
3446 return MLang_AddRef( This
);
3449 static ULONG WINAPI
fnIMLangLineBreakConsole_Release(
3450 IMLangLineBreakConsole
* iface
)
3452 MLang_impl
*This
= impl_from_IMLangLineBreakConsole( iface
);
3453 return MLang_Release( This
);
3456 static HRESULT WINAPI
fnIMLangLineBreakConsole_BreakLineML(
3457 IMLangLineBreakConsole
* iface
,
3458 IMLangString
* pSrcMLStr
,
3466 FIXME("(%p)->%p %i %i %i %i %p %p\n", iface
, pSrcMLStr
, lSrcPos
, lSrcLen
, cMinColumns
, cMaxColumns
, plLineLen
, plSkipLen
);
3470 static HRESULT WINAPI
fnIMLangLineBreakConsole_BreakLineW(
3471 IMLangLineBreakConsole
* iface
,
3473 const WCHAR
* pszSrc
,
3479 FIXME("(%p)->%i %s %i %i %p %p\n", iface
, locale
, debugstr_wn(pszSrc
,cchSrc
), cchSrc
, cMaxColumns
, pcchLine
, pcchSkip
);
3486 static HRESULT WINAPI
fnIMLangLineBreakConsole_BreakLineA(
3487 IMLangLineBreakConsole
* iface
,
3496 FIXME("(%p)->%i %i %s %i %i %p %p\n", iface
, locale
, uCodePage
, debugstr_an(pszSrc
,cchSrc
), cchSrc
, cMaxColumns
, pcchLine
, pcchSkip
);
3503 static const IMLangLineBreakConsoleVtbl IMLangLineBreakConsole_vtbl
=
3505 fnIMLangLineBreakConsole_QueryInterface
,
3506 fnIMLangLineBreakConsole_AddRef
,
3507 fnIMLangLineBreakConsole_Release
,
3508 fnIMLangLineBreakConsole_BreakLineML
,
3509 fnIMLangLineBreakConsole_BreakLineW
,
3510 fnIMLangLineBreakConsole_BreakLineA
3513 static HRESULT
MultiLanguage_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
3518 TRACE("Creating MultiLanguage object\n");
3521 return CLASS_E_NOAGGREGATION
;
3523 mlang
= HeapAlloc( GetProcessHeap(), 0, sizeof (MLang_impl
) );
3524 mlang
->vtbl_IMLangFontLink
= &IMLangFontLink_vtbl
;
3525 mlang
->vtbl_IMultiLanguage
= &IMultiLanguage_vtbl
;
3526 mlang
->vtbl_IMultiLanguage3
= &IMultiLanguage3_vtbl
;
3527 mlang
->vtbl_IMLangFontLink2
= &IMLangFontLink2_vtbl
;
3528 mlang
->vtbl_IMLangLineBreakConsole
= &IMLangLineBreakConsole_vtbl
;
3530 mlang
->total_cp
= 0;
3531 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
3532 mlang
->total_cp
+= mlang_data
[i
].number_of_cp
;
3534 /* do not enumerate unicode flavours */
3535 mlang
->total_scripts
= sizeof(mlang_data
)/sizeof(mlang_data
[0]) - 1;
3539 TRACE("returning %p\n", mlang
);
3546 /******************************************************************************/
3548 HRESULT WINAPI
DllCanUnloadNow(void)
3550 return dll_count
== 0 ? S_OK
: S_FALSE
;
3553 HRESULT WINAPI
GetGlobalFontLinkObject(void)