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
);
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 (Shift-JIS)",
261 932, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
262 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
263 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
264 MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
265 "shift_jis", "iso-2022-jp", "iso-2022-jp" },
266 { "Japanese (JIS 0208-1990 and 0212-1990)",
267 20932, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
268 MIMECONTF_MIME_LATEST
,
269 "euc-jp", "euc-jp", "euc-jp" }
271 static const MIME_CP_INFO korean_cp
[] =
274 949, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
275 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
276 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
|
277 MIMECONTF_MIME_LATEST
,
278 "ks_c_5601-1987", "ks_c_5601-1987", "ks_c_5601-1987" }
280 static const MIME_CP_INFO thai_cp
[] =
283 874, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_MIME_LATEST
,
284 "ibm-thai", "ibm-thai", "ibm-thai" }
286 static const MIME_CP_INFO turkish_cp
[] =
289 857, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
290 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
291 "ibm857", "ibm857", "ibm857" },
292 { "IBM EBCDIC (Turkish Latin-5)",
293 1026, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
294 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
295 "ibm1026", "ibm1026", "ibm1026" },
296 { "Turkish (Windows)",
297 1254, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
298 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
299 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
300 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
301 "windows-1254", "windows-1254", "windows-1254" },
303 10081, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
304 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
305 "x-mac-turkish", "x-mac-turkish", "x-mac-turkish" },
307 28593, MIMECONTF_MAILNEWS
| MIMECONTF_IMPORT
|
308 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
309 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
310 "iso-8859-3", "iso-8859-3", "iso-8859-3" },
312 28599, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
313 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
314 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
315 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
316 "iso-8859-9", "iso-8859-9", "iso-8859-9" }
318 static const MIME_CP_INFO vietnamese_cp
[] =
320 { "Vietnamese (Windows)",
321 1258, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
322 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
323 MIMECONTF_EXPORT
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
|
324 MIMECONTF_MIME_LATEST
,
325 "windows-1258", "windows-1258", "windows-1258" }
327 static const MIME_CP_INFO western_cp
[] =
329 { "IBM EBCDIC (US-Canada)",
330 37, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
331 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
332 "ibm037", "ibm037", "ibm037" },
333 { "OEM United States",
334 437, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
335 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
336 "ibm437", "ibm437", "ibm437" },
337 { "IBM EBCDIC (International)",
338 500, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
339 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
340 "ibm500", "ibm500", "ibm500" },
341 { "Western European (DOS)",
342 850, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
343 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
344 "ibm850", "ibm850", "ibm850" },
345 { "Portuguese (DOS)",
346 860, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
347 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
348 "ibm860", "ibm860", "ibm860" },
350 861, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
351 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
352 "ibm861", "ibm861", "ibm861" },
353 { "French Canadian (DOS)",
354 863, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
355 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
356 "ibm863", "ibm863", "ibm863" },
358 865, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
359 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
360 "ibm865", "ibm865", "ibm865" },
361 { "Western European (Windows)",
362 1252, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_MINIMAL
|
363 MIMECONTF_IMPORT
| MIMECONTF_SAVABLE_MAILNEWS
|
364 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
365 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
366 "windows-1252", "windows-1252", "iso-8859-1" },
367 { "Western European (Mac)",
368 10000, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
369 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
370 "macintosh", "macintosh", "macintosh" },
372 10079, MIMECONTF_IMPORT
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
373 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
374 "x-mac-icelandic", "x-mac-icelandic", "x-mac-icelandic" },
376 20127, MIMECONTF_MAILNEWS
| MIMECONTF_IMPORT
| MIMECONTF_EXPORT
|
377 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_VALID
|
378 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_LATEST
,
379 "us-ascii", "us-ascii", "us-ascii" },
380 { "Western European (ISO)",
381 28591, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
382 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
383 MIMECONTF_EXPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
384 MIMECONTF_MIME_LATEST
,
385 "iso-8859-1", "iso-8859-1", "iso-8859-1" },
387 28605, MIMECONTF_MAILNEWS
| MIMECONTF_IMPORT
|
388 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
389 MIMECONTF_EXPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
390 MIMECONTF_MIME_LATEST
,
391 "iso-8859-15", "iso-8859-15", "iso-8859-15" }
393 static const MIME_CP_INFO unicode_cp
[] =
396 CP_UNICODE
, MIMECONTF_MINIMAL
| MIMECONTF_IMPORT
|
397 MIMECONTF_SAVABLE_BROWSER
| MIMECONTF_EXPORT
|
398 MIMECONTF_VALID
| MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
|
399 MIMECONTF_MIME_LATEST
,
400 "unicode", "unicode", "unicode" },
402 CP_UTF7
, MIMECONTF_MAILNEWS
| MIMECONTF_IMPORT
|
403 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_EXPORT
| MIMECONTF_VALID
|
404 MIMECONTF_VALID_NLS
| MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
405 "utf-7", "utf-7", "utf-7" },
407 CP_UTF8
, MIMECONTF_MAILNEWS
| MIMECONTF_BROWSER
| MIMECONTF_IMPORT
|
408 MIMECONTF_SAVABLE_MAILNEWS
| MIMECONTF_SAVABLE_BROWSER
|
409 MIMECONTF_EXPORT
| MIMECONTF_VALID
| MIMECONTF_VALID_NLS
|
410 MIMECONTF_MIME_IE4
| MIMECONTF_MIME_LATEST
,
411 "utf-8", "utf-8", "utf-8" }
414 static const struct mlang_data
416 const char *description
;
417 UINT family_codepage
;
419 const MIME_CP_INFO
*mime_cp_info
;
420 const char *fixed_font
;
421 const char *proportional_font
;
424 { "Arabic",1256,sizeof(arabic_cp
)/sizeof(arabic_cp
[0]),arabic_cp
,
425 "Courier","Arial" }, /* FIXME */
426 { "Baltic",1257,sizeof(baltic_cp
)/sizeof(baltic_cp
[0]),baltic_cp
,
427 "Courier","Arial" }, /* FIXME */
428 { "Chinese Simplified",936,sizeof(chinese_simplified_cp
)/sizeof(chinese_simplified_cp
[0]),chinese_simplified_cp
,
429 "Courier","Arial" }, /* FIXME */
430 { "Chinese Traditional",950,sizeof(chinese_traditional_cp
)/sizeof(chinese_traditional_cp
[0]),chinese_traditional_cp
,
431 "Courier","Arial" }, /* FIXME */
432 { "Central European",1250,sizeof(central_european_cp
)/sizeof(central_european_cp
[0]),central_european_cp
,
433 "Courier","Arial" }, /* FIXME */
434 { "Cyrillic",1251,sizeof(cyrillic_cp
)/sizeof(cyrillic_cp
[0]),cyrillic_cp
,
435 "Courier","Arial" }, /* FIXME */
436 { "Greek",1253,sizeof(greek_cp
)/sizeof(greek_cp
[0]),greek_cp
,
437 "Courier","Arial" }, /* FIXME */
438 { "Hebrew",1255,sizeof(hebrew_cp
)/sizeof(hebrew_cp
[0]),hebrew_cp
,
439 "Courier","Arial" }, /* FIXME */
440 { "Japanese",932,sizeof(japanese_cp
)/sizeof(japanese_cp
[0]),japanese_cp
,
441 "Courier","Arial" }, /* FIXME */
442 { "Korean",949,sizeof(korean_cp
)/sizeof(korean_cp
[0]),korean_cp
,
443 "Courier","Arial" }, /* FIXME */
444 { "Thai",874,sizeof(thai_cp
)/sizeof(thai_cp
[0]),thai_cp
,
445 "Courier","Arial" }, /* FIXME */
446 { "Turkish",1254,sizeof(turkish_cp
)/sizeof(turkish_cp
[0]),turkish_cp
,
447 "Courier","Arial" }, /* FIXME */
448 { "Vietnamese",1258,sizeof(vietnamese_cp
)/sizeof(vietnamese_cp
[0]),vietnamese_cp
,
449 "Courier","Arial" }, /* FIXME */
450 { "Western European",1252,sizeof(western_cp
)/sizeof(western_cp
[0]),western_cp
,
451 "Courier","Arial" }, /* FIXME */
452 { "Unicode",CP_UNICODE
,sizeof(unicode_cp
)/sizeof(unicode_cp
[0]),unicode_cp
,
453 "Courier","Arial" } /* FIXME */
456 static void fill_cp_info(const struct mlang_data
*ml_data
, UINT index
, MIMECPINFO
*mime_cp_info
);
458 static LONG dll_count
;
461 * Dll lifetime tracking declaration
463 static void LockModule(void)
465 InterlockedIncrement(&dll_count
);
468 static void UnlockModule(void)
470 InterlockedDecrement(&dll_count
);
473 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
476 case DLL_PROCESS_ATTACH
:
477 MLANG_tls_index
= TlsAlloc();
478 DisableThreadLibraryCalls(hInstDLL
);
480 case DLL_PROCESS_DETACH
:
481 TlsFree(MLANG_tls_index
);
487 HRESULT WINAPI
ConvertINetMultiByteToUnicode(
497 TRACE("%p %d %s %p %p %p\n", pdwMode
, dwEncoding
,
498 debugstr_a(pSrcStr
), pcSrcSize
, pDstStr
, pcDstSize
);
504 pcSrcSize
= &src_len
;
515 if (*pcSrcSize
== -1)
516 *pcSrcSize
= lstrlenW((LPCWSTR
)pSrcStr
);
517 *pcDstSize
= min(*pcSrcSize
, *pcDstSize
);
518 *pcSrcSize
*= sizeof(WCHAR
);
520 memmove(pDstStr
, pSrcStr
, *pcDstSize
* sizeof(WCHAR
));
524 if (*pcSrcSize
== -1)
525 *pcSrcSize
= lstrlenA(pSrcStr
);
528 *pcDstSize
= MultiByteToWideChar(dwEncoding
, 0, pSrcStr
, *pcSrcSize
, pDstStr
, *pcDstSize
);
530 *pcDstSize
= MultiByteToWideChar(dwEncoding
, 0, pSrcStr
, *pcSrcSize
, NULL
, 0);
540 HRESULT WINAPI
ConvertINetUnicodeToMultiByte(
551 TRACE("%p %d %s %p %p %p\n", pdwMode
, dwEncoding
,
552 debugstr_w(pSrcStr
), pcSrcSize
, pDstStr
, pcDstSize
);
558 pcSrcSize
= &src_len
;
569 if (*pcSrcSize
== -1)
570 *pcSrcSize
= lstrlenW(pSrcStr
);
571 *pcDstSize
= min(*pcSrcSize
* sizeof(WCHAR
), *pcDstSize
);
573 memmove(pDstStr
, pSrcStr
, *pcDstSize
);
577 if (*pcSrcSize
== -1)
578 *pcSrcSize
= lstrlenW(pSrcStr
);
581 *pcDstSize
= WideCharToMultiByte(dwEncoding
, 0, pSrcStr
, *pcSrcSize
, pDstStr
, *pcDstSize
, NULL
, NULL
);
583 *pcDstSize
= WideCharToMultiByte(dwEncoding
, 0, pSrcStr
, *pcSrcSize
, NULL
, 0, NULL
, NULL
);
594 HRESULT WINAPI
ConvertINetString(
604 TRACE("%p %d %d %s %p %p %p\n", pdwMode
, dwSrcEncoding
, dwDstEncoding
,
605 debugstr_a(pSrcStr
), pcSrcSize
, pDstStr
, pcDstSize
);
607 if (dwSrcEncoding
== CP_UNICODE
)
610 if (pcSrcSize
&& *pcSrcSize
!= -1)
612 cSrcSizeW
= *pcSrcSize
/ sizeof(WCHAR
);
613 pcSrcSize
= &cSrcSizeW
;
615 return ConvertINetUnicodeToMultiByte(pdwMode
, dwDstEncoding
, (LPCWSTR
)pSrcStr
, pcSrcSize
, pDstStr
, pcDstSize
);
617 else if (dwDstEncoding
== CP_UNICODE
)
619 HRESULT hr
= ConvertINetMultiByteToUnicode(pdwMode
, dwSrcEncoding
, pSrcStr
, pcSrcSize
, (LPWSTR
)pDstStr
, pcDstSize
);
620 *pcDstSize
*= sizeof(WCHAR
);
629 TRACE("convert %s from %d to %d\n", debugstr_a(pSrcStr
), dwSrcEncoding
, dwDstEncoding
);
631 hr
= ConvertINetMultiByteToUnicode(pdwMode
, dwSrcEncoding
, pSrcStr
, pcSrcSize
, NULL
, &cDstSizeW
);
635 pDstStrW
= HeapAlloc(GetProcessHeap(), 0, cDstSizeW
* sizeof(WCHAR
));
636 hr
= ConvertINetMultiByteToUnicode(pdwMode
, dwSrcEncoding
, pSrcStr
, pcSrcSize
, pDstStrW
, &cDstSizeW
);
640 hr
= ConvertINetUnicodeToMultiByte(pdwMode
, dwDstEncoding
, pDstStrW
, &cDstSizeW
, pDstStr
, pcDstSize
);
641 HeapFree(GetProcessHeap(), 0, pDstStrW
);
646 static HRESULT
GetFamilyCodePage(
648 UINT
* puiFamilyCodePage
)
652 TRACE("%u %p\n", uiCodePage
, puiFamilyCodePage
);
654 if (!puiFamilyCodePage
) return S_FALSE
;
656 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
658 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
660 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
662 *puiFamilyCodePage
= mlang_data
[i
].family_codepage
;
671 HRESULT WINAPI
IsConvertINetStringAvailable(
675 UINT src_family
, dst_family
;
677 TRACE("%d %d\n", dwSrcEncoding
, dwDstEncoding
);
679 if (GetFamilyCodePage(dwSrcEncoding
, &src_family
) != S_OK
||
680 GetFamilyCodePage(dwDstEncoding
, &dst_family
) != S_OK
)
683 if (src_family
== dst_family
) return S_OK
;
685 /* we can convert any codepage to/from unicode */
686 if (src_family
== CP_UNICODE
|| dst_family
== CP_UNICODE
) return S_OK
;
691 static inline INT
lcid_to_rfc1766A( LCID lcid
, LPSTR rfc1766
, INT len
)
693 INT n
= GetLocaleInfoA( lcid
, LOCALE_SISO639LANGNAME
, rfc1766
, len
);
696 rfc1766
[n
- 1] = '-';
697 n
+= GetLocaleInfoA( lcid
, LOCALE_SISO3166CTRYNAME
, rfc1766
+ n
, len
- n
) + 1;
698 LCMapStringA( LOCALE_USER_DEFAULT
, LCMAP_LOWERCASE
, rfc1766
, n
, rfc1766
, len
);
704 static inline INT
lcid_to_rfc1766W( LCID lcid
, LPWSTR rfc1766
, INT len
)
706 INT n
= GetLocaleInfoW( lcid
, LOCALE_SISO639LANGNAME
, rfc1766
, len
);
709 rfc1766
[n
- 1] = '-';
710 n
+= GetLocaleInfoW( lcid
, LOCALE_SISO3166CTRYNAME
, rfc1766
+ n
, len
- n
) + 1;
711 LCMapStringW( LOCALE_USER_DEFAULT
, LCMAP_LOWERCASE
, rfc1766
, n
, rfc1766
, len
);
717 HRESULT WINAPI
LcidToRfc1766A(
722 TRACE("%04x %p %u\n", lcid
, pszRfc1766
, nChar
);
724 if (lcid_to_rfc1766A( lcid
, pszRfc1766
, nChar
))
730 HRESULT WINAPI
LcidToRfc1766W(
735 TRACE("%04x %p %u\n", lcid
, pszRfc1766
, nChar
);
737 if (lcid_to_rfc1766W( lcid
, pszRfc1766
, nChar
))
743 /******************************************************************************
747 IClassFactory ITF_IClassFactory
;
750 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
753 struct object_creation_info
757 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
760 static const struct object_creation_info object_creation
[] =
762 { &CLSID_CMultiLanguage
, "CLSID_CMultiLanguage", MultiLanguage_create
},
765 static HRESULT WINAPI
766 MLANGCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
)
768 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
770 TRACE("%s\n", debugstr_guid(riid
) );
772 if (IsEqualGUID(riid
, &IID_IUnknown
)
773 || IsEqualGUID(riid
, &IID_IClassFactory
))
775 IClassFactory_AddRef(iface
);
780 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
781 return E_NOINTERFACE
;
784 static ULONG WINAPI
MLANGCF_AddRef(LPCLASSFACTORY iface
)
786 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
787 return InterlockedIncrement(&This
->ref
);
790 static ULONG WINAPI
MLANGCF_Release(LPCLASSFACTORY iface
)
792 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
794 ULONG ref
= InterlockedDecrement(&This
->ref
);
798 TRACE("Destroying %p\n", This
);
799 HeapFree(GetProcessHeap(), 0, This
);
805 static HRESULT WINAPI
MLANGCF_CreateInstance(LPCLASSFACTORY iface
, LPUNKNOWN pOuter
,
806 REFIID riid
, LPVOID
*ppobj
)
808 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
812 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
815 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
816 if (SUCCEEDED(hres
)) {
817 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
818 IUnknown_Release(punk
);
820 TRACE("returning (%p) -> %x\n", *ppobj
, hres
);
824 static HRESULT WINAPI
MLANGCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
)
834 static const IClassFactoryVtbl MLANGCF_Vtbl
=
836 MLANGCF_QueryInterface
,
839 MLANGCF_CreateInstance
,
843 /******************************************************************
844 * DllGetClassObject (MLANG.@)
846 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
849 IClassFactoryImpl
*factory
;
851 TRACE("%s %s %p\n",debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
853 if ( !IsEqualGUID( &IID_IClassFactory
, iid
)
854 && ! IsEqualGUID( &IID_IUnknown
, iid
) )
855 return E_NOINTERFACE
;
857 for (i
=0; i
< sizeof(object_creation
)/sizeof(object_creation
[0]); i
++)
859 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
863 if (i
== sizeof(object_creation
)/sizeof(object_creation
[0]))
865 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
866 return CLASS_E_CLASSNOTAVAILABLE
;
869 TRACE("Creating a class factory for %s\n",object_creation
[i
].szClassName
);
871 factory
= HeapAlloc(GetProcessHeap(), 0, sizeof(*factory
));
872 if (factory
== NULL
) return E_OUTOFMEMORY
;
874 factory
->ITF_IClassFactory
.lpVtbl
= &MLANGCF_Vtbl
;
877 factory
->pfnCreateInstance
= object_creation
[i
].pfnCreateInstance
;
879 *ppv
= &(factory
->ITF_IClassFactory
);
881 TRACE("(%p) <- %p\n", ppv
, &(factory
->ITF_IClassFactory
) );
887 /******************************************************************************/
889 typedef struct tagMLang_impl
891 const IMLangFontLinkVtbl
*vtbl_IMLangFontLink
;
892 const IMultiLanguageVtbl
*vtbl_IMultiLanguage
;
893 const IMultiLanguage3Vtbl
*vtbl_IMultiLanguage3
;
895 DWORD total_cp
, total_scripts
;
898 static ULONG WINAPI
MLang_AddRef( MLang_impl
* This
)
900 return InterlockedIncrement(&This
->ref
);
903 static ULONG WINAPI
MLang_Release( MLang_impl
* This
)
905 ULONG ref
= InterlockedDecrement(&This
->ref
);
907 TRACE("%p ref = %d\n", This
, ref
);
910 TRACE("Destroying %p\n", This
);
911 HeapFree(GetProcessHeap(), 0, This
);
918 static HRESULT WINAPI
MLang_QueryInterface(
923 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
925 if (IsEqualGUID(riid
, &IID_IUnknown
)
926 || IsEqualGUID(riid
, &IID_IMLangCodePages
)
927 || IsEqualGUID(riid
, &IID_IMLangFontLink
))
930 TRACE("Returning IID_IMLangFontLink %p ref = %d\n", This
, This
->ref
);
931 *ppvObject
= &(This
->vtbl_IMLangFontLink
);
935 if (IsEqualGUID(riid
, &IID_IMultiLanguage
) )
938 TRACE("Returning IID_IMultiLanguage %p ref = %d\n", This
, This
->ref
);
939 *ppvObject
= &(This
->vtbl_IMultiLanguage
);
943 if (IsEqualGUID(riid
, &IID_IMultiLanguage2
) )
946 *ppvObject
= &(This
->vtbl_IMultiLanguage3
);
947 TRACE("Returning IID_IMultiLanguage2 %p ref = %d\n", This
, This
->ref
);
951 if (IsEqualGUID(riid
, &IID_IMultiLanguage3
) )
954 *ppvObject
= &(This
->vtbl_IMultiLanguage3
);
955 TRACE("Returning IID_IMultiLanguage3 %p ref = %d\n", This
, This
->ref
);
959 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
960 return E_NOINTERFACE
;
963 /******************************************************************************/
965 typedef struct tagEnumCodePage_impl
967 const IEnumCodePageVtbl
*vtbl_IEnumCodePage
;
973 static HRESULT WINAPI
fnIEnumCodePage_QueryInterface(
974 IEnumCodePage
* iface
,
978 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
980 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
982 if (IsEqualGUID(riid
, &IID_IUnknown
)
983 || IsEqualGUID(riid
, &IID_IEnumCodePage
))
985 IEnumCodePage_AddRef(iface
);
986 TRACE("Returning IID_IEnumCodePage %p ref = %d\n", This
, This
->ref
);
987 *ppvObject
= &(This
->vtbl_IEnumCodePage
);
991 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
992 return E_NOINTERFACE
;
995 static ULONG WINAPI
fnIEnumCodePage_AddRef(
996 IEnumCodePage
* iface
)
998 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
999 return InterlockedIncrement(&This
->ref
);
1002 static ULONG WINAPI
fnIEnumCodePage_Release(
1003 IEnumCodePage
* iface
)
1005 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1006 ULONG ref
= InterlockedDecrement(&This
->ref
);
1008 TRACE("%p ref = %d\n", This
, ref
);
1011 TRACE("Destroying %p\n", This
);
1012 HeapFree(GetProcessHeap(), 0, This
->cpinfo
);
1013 HeapFree(GetProcessHeap(), 0, This
);
1019 static HRESULT WINAPI
fnIEnumCodePage_Clone(
1020 IEnumCodePage
* iface
,
1021 IEnumCodePage
** ppEnum
)
1023 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1024 FIXME("%p %p\n", This
, ppEnum
);
1028 static HRESULT WINAPI
fnIEnumCodePage_Next(
1029 IEnumCodePage
* iface
,
1032 ULONG
* pceltFetched
)
1036 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1037 TRACE("%p %u %p %p\n", This
, celt
, rgelt
, pceltFetched
);
1039 if (!pceltFetched
) return S_FALSE
;
1042 if (!rgelt
) return S_FALSE
;
1044 if (This
->pos
+ celt
> This
->total
)
1045 celt
= This
->total
- This
->pos
;
1047 if (!celt
) return S_FALSE
;
1049 memcpy(rgelt
, This
->cpinfo
+ This
->pos
, celt
* sizeof(MIMECPINFO
));
1050 *pceltFetched
= celt
;
1053 for (i
= 0; i
< celt
; i
++)
1055 TRACE("#%u: %08x %u %u %s %s %s %s %s %s %d\n",
1056 i
, rgelt
[i
].dwFlags
, rgelt
[i
].uiCodePage
,
1057 rgelt
[i
].uiFamilyCodePage
,
1058 wine_dbgstr_w(rgelt
[i
].wszDescription
),
1059 wine_dbgstr_w(rgelt
[i
].wszWebCharset
),
1060 wine_dbgstr_w(rgelt
[i
].wszHeaderCharset
),
1061 wine_dbgstr_w(rgelt
[i
].wszBodyCharset
),
1062 wine_dbgstr_w(rgelt
[i
].wszFixedWidthFont
),
1063 wine_dbgstr_w(rgelt
[i
].wszProportionalFont
),
1064 rgelt
[i
].bGDICharset
);
1069 static HRESULT WINAPI
fnIEnumCodePage_Reset(
1070 IEnumCodePage
* iface
)
1072 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1073 TRACE("%p\n", This
);
1079 static HRESULT WINAPI
fnIEnumCodePage_Skip(
1080 IEnumCodePage
* iface
,
1083 ICOM_THIS_MULTI(EnumCodePage_impl
, vtbl_IEnumCodePage
, iface
);
1084 TRACE("%p %u\n", This
, celt
);
1086 if (celt
>= This
->total
) return S_FALSE
;
1092 static const IEnumCodePageVtbl IEnumCodePage_vtbl
=
1094 fnIEnumCodePage_QueryInterface
,
1095 fnIEnumCodePage_AddRef
,
1096 fnIEnumCodePage_Release
,
1097 fnIEnumCodePage_Clone
,
1098 fnIEnumCodePage_Next
,
1099 fnIEnumCodePage_Reset
,
1100 fnIEnumCodePage_Skip
1103 static HRESULT
EnumCodePage_create( MLang_impl
* mlang
, DWORD grfFlags
,
1104 LANGID LangId
, IEnumCodePage
** ppEnumCodePage
)
1106 EnumCodePage_impl
*ecp
;
1110 TRACE("%p, %08x, %04x, %p\n", mlang
, grfFlags
, LangId
, ppEnumCodePage
);
1112 if (!grfFlags
) /* enumerate internal data base of encodings */
1113 grfFlags
= MIMECONTF_MIME_LATEST
;
1115 ecp
= HeapAlloc( GetProcessHeap(), 0, sizeof (EnumCodePage_impl
) );
1116 ecp
->vtbl_IEnumCodePage
= &IEnumCodePage_vtbl
;
1120 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
1122 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
1124 if (mlang_data
[i
].mime_cp_info
[n
].flags
& grfFlags
)
1129 ecp
->cpinfo
= HeapAlloc(GetProcessHeap(), 0,
1130 sizeof(MIMECPINFO
) * ecp
->total
);
1131 cpinfo
= ecp
->cpinfo
;
1133 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
1135 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
1137 if (mlang_data
[i
].mime_cp_info
[n
].flags
& grfFlags
)
1138 fill_cp_info(&mlang_data
[i
], n
, cpinfo
++);
1142 TRACE("enumerated %d codepages with flags %08x\n", ecp
->total
, grfFlags
);
1144 *ppEnumCodePage
= (IEnumCodePage
*) ecp
;
1149 /******************************************************************************/
1151 typedef struct tagEnumScript_impl
1153 const IEnumScriptVtbl
*vtbl_IEnumScript
;
1155 SCRIPTINFO
*script_info
;
1159 static HRESULT WINAPI
fnIEnumScript_QueryInterface(
1164 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1166 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
1168 if (IsEqualGUID(riid
, &IID_IUnknown
)
1169 || IsEqualGUID(riid
, &IID_IEnumScript
))
1171 IEnumScript_AddRef(iface
);
1172 TRACE("Returning IID_IEnumScript %p ref = %d\n", This
, This
->ref
);
1173 *ppvObject
= &(This
->vtbl_IEnumScript
);
1177 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
1178 return E_NOINTERFACE
;
1181 static ULONG WINAPI
fnIEnumScript_AddRef(
1184 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1185 return InterlockedIncrement(&This
->ref
);
1188 static ULONG WINAPI
fnIEnumScript_Release(
1191 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1192 ULONG ref
= InterlockedDecrement(&This
->ref
);
1194 TRACE("%p ref = %d\n", This
, ref
);
1197 TRACE("Destroying %p\n", This
);
1198 HeapFree(GetProcessHeap(), 0, This
);
1204 static HRESULT WINAPI
fnIEnumScript_Clone(
1206 IEnumScript
** ppEnum
)
1208 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1209 FIXME("%p %p: stub!\n", This
, ppEnum
);
1213 static HRESULT WINAPI
fnIEnumScript_Next(
1217 ULONG
* pceltFetched
)
1219 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1220 TRACE("%p %u %p %p\n", This
, celt
, rgelt
, pceltFetched
);
1222 if (!pceltFetched
|| !rgelt
) return E_FAIL
;
1226 if (This
->pos
+ celt
> This
->total
)
1227 celt
= This
->total
- This
->pos
;
1229 if (!celt
) return S_FALSE
;
1231 memcpy(rgelt
, This
->script_info
+ This
->pos
, celt
* sizeof(SCRIPTINFO
));
1232 *pceltFetched
= celt
;
1238 static HRESULT WINAPI
fnIEnumScript_Reset(
1241 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1242 TRACE("%p\n", This
);
1248 static HRESULT WINAPI
fnIEnumScript_Skip(
1252 ICOM_THIS_MULTI(EnumScript_impl
, vtbl_IEnumScript
, iface
);
1253 TRACE("%p %u\n", This
, celt
);
1255 if (celt
>= This
->total
) return S_FALSE
;
1261 static const IEnumScriptVtbl IEnumScript_vtbl
=
1263 fnIEnumScript_QueryInterface
,
1264 fnIEnumScript_AddRef
,
1265 fnIEnumScript_Release
,
1266 fnIEnumScript_Clone
,
1268 fnIEnumScript_Reset
,
1272 static HRESULT
EnumScript_create( MLang_impl
* mlang
, DWORD dwFlags
,
1273 LANGID LangId
, IEnumScript
** ppEnumScript
)
1275 EnumScript_impl
*es
;
1278 TRACE("%p, %08x, %04x, %p: stub!\n", mlang
, dwFlags
, LangId
, ppEnumScript
);
1280 if (!dwFlags
) /* enumerate all available scripts */
1281 dwFlags
= SCRIPTCONTF_SCRIPT_USER
| SCRIPTCONTF_SCRIPT_HIDE
| SCRIPTCONTF_SCRIPT_SYSTEM
;
1283 es
= HeapAlloc( GetProcessHeap(), 0, sizeof (EnumScript_impl
) );
1284 es
->vtbl_IEnumScript
= &IEnumScript_vtbl
;
1287 /* do not enumerate unicode flavours */
1288 es
->total
= sizeof(mlang_data
)/sizeof(mlang_data
[0]) - 1;
1289 es
->script_info
= HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPTINFO
) * es
->total
);
1291 for (i
= 0; i
< es
->total
; i
++)
1293 es
->script_info
[i
].ScriptId
= i
;
1294 es
->script_info
[i
].uiCodePage
= mlang_data
[i
].family_codepage
;
1295 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].description
, -1,
1296 es
->script_info
[i
].wszDescription
, MAX_SCRIPT_NAME
);
1297 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].fixed_font
, -1,
1298 es
->script_info
[i
].wszFixedWidthFont
, MAX_MIMEFACE_NAME
);
1299 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].proportional_font
, -1,
1300 es
->script_info
[i
].wszProportionalFont
, MAX_MIMEFACE_NAME
);
1303 TRACE("enumerated %d scripts with flags %08x\n", es
->total
, dwFlags
);
1305 *ppEnumScript
= (IEnumScript
*)es
;
1310 /******************************************************************************/
1312 static HRESULT WINAPI
fnIMLangFontLink_QueryInterface(
1313 IMLangFontLink
* iface
,
1317 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1318 return MLang_QueryInterface( This
, riid
, ppvObject
);
1321 static ULONG WINAPI
fnIMLangFontLink_AddRef(
1322 IMLangFontLink
* iface
)
1324 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1325 return MLang_AddRef( This
);
1328 static ULONG WINAPI
fnIMLangFontLink_Release(
1329 IMLangFontLink
* iface
)
1331 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1332 return MLang_Release( This
);
1335 static HRESULT WINAPI
fnIMLangFontLink_GetCharCodePages(
1336 IMLangFontLink
* iface
,
1338 DWORD
* pdwCodePages
)
1344 static HRESULT WINAPI
fnIMLangFontLink_GetStrCodePages(
1345 IMLangFontLink
* iface
,
1346 const WCHAR
* pszSrc
,
1348 DWORD dwPriorityCodePages
,
1349 DWORD
* pdwCodePages
,
1350 long* pcchCodePages
)
1352 FIXME("(pszSrc=%s, cchSrc=%ld, dwPriorityCodePages=%d) stub\n", debugstr_w(pszSrc
), cchSrc
, dwPriorityCodePages
);
1358 static HRESULT WINAPI
fnIMLangFontLink_CodePageToCodePages(
1359 IMLangFontLink
* iface
,
1361 DWORD
* pdwCodePages
)
1363 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1367 TRACE("(%p) Seeking %u\n",This
, uCodePage
);
1368 memset(&cs
, 0, sizeof(cs
));
1370 rc
= TranslateCharsetInfo((DWORD
*)uCodePage
, &cs
, TCI_SRCCODEPAGE
);
1374 *pdwCodePages
= cs
.fs
.fsCsb
[0];
1375 TRACE("resulting CodePages 0x%x\n",*pdwCodePages
);
1378 TRACE("CodePage Not Found\n");
1383 static HRESULT WINAPI
fnIMLangFontLink_CodePagesToCodePage(
1384 IMLangFontLink
* iface
,
1386 UINT uDefaultCodePage
,
1389 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1390 DWORD mask
= 0x00000000;
1395 TRACE("(%p) scanning 0x%x default page %u\n",This
, dwCodePages
,
1398 *puCodePage
= 0x00000000;
1400 rc
= TranslateCharsetInfo((DWORD
*)uDefaultCodePage
, &cs
, TCI_SRCCODEPAGE
);
1402 if (rc
&& (dwCodePages
& cs
.fs
.fsCsb
[0]))
1404 TRACE("Found Default Codepage\n");
1405 *puCodePage
= uDefaultCodePage
;
1410 for (i
= 0; i
< 32; i
++)
1414 if (dwCodePages
& mask
)
1419 rc
= TranslateCharsetInfo((DWORD
*)Csb
, &cs
, TCI_SRCFONTSIG
);
1423 TRACE("Falling back to least significant found CodePage %u\n",
1425 *puCodePage
= cs
.ciACP
;
1430 TRACE("no codepage found\n");
1434 static HRESULT WINAPI
fnIMLangFontLink_GetFontCodePages(
1435 IMLangFontLink
* iface
,
1438 DWORD
* pdwCodePages
)
1441 FONTSIGNATURE fontsig
;
1442 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMLangFontLink
, iface
);
1444 TRACE("(%p)\n",This
);
1446 old_font
= SelectObject(hDC
,hFont
);
1447 GetTextCharsetInfo(hDC
,&fontsig
, 0);
1448 SelectObject(hDC
,old_font
);
1450 *pdwCodePages
= fontsig
.fsCsb
[0];
1451 TRACE("CodePages is 0x%x\n",fontsig
.fsCsb
[0]);
1456 static HRESULT WINAPI
fnIMLangFontLink_MapFont(
1457 IMLangFontLink
* iface
,
1467 static HRESULT WINAPI
fnIMLangFontLink_ReleaseFont(
1468 IMLangFontLink
* iface
,
1475 static HRESULT WINAPI
fnIMLangFontLink_ResetFontMapping(
1476 IMLangFontLink
* iface
)
1483 static const IMLangFontLinkVtbl IMLangFontLink_vtbl
=
1485 fnIMLangFontLink_QueryInterface
,
1486 fnIMLangFontLink_AddRef
,
1487 fnIMLangFontLink_Release
,
1488 fnIMLangFontLink_GetCharCodePages
,
1489 fnIMLangFontLink_GetStrCodePages
,
1490 fnIMLangFontLink_CodePageToCodePages
,
1491 fnIMLangFontLink_CodePagesToCodePage
,
1492 fnIMLangFontLink_GetFontCodePages
,
1493 fnIMLangFontLink_MapFont
,
1494 fnIMLangFontLink_ReleaseFont
,
1495 fnIMLangFontLink_ResetFontMapping
,
1498 /******************************************************************************/
1500 static HRESULT WINAPI
fnIMultiLanguage_QueryInterface(
1501 IMultiLanguage
* iface
,
1505 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
1506 return MLang_QueryInterface( This
, riid
, ppvObject
);
1509 static ULONG WINAPI
fnIMultiLanguage_AddRef( IMultiLanguage
* iface
)
1511 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
1512 return IMLangFontLink_AddRef( ((IMLangFontLink
*)This
) );
1515 static ULONG WINAPI
fnIMultiLanguage_Release( IMultiLanguage
* iface
)
1517 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
1518 return IMLangFontLink_Release( ((IMLangFontLink
*)This
) );
1521 static HRESULT WINAPI
fnIMultiLanguage_GetNumberOfCodePageInfo(
1522 IMultiLanguage
* iface
,
1529 static HRESULT WINAPI
fnIMultiLanguage_GetCodePageInfo(
1530 IMultiLanguage
* iface
,
1532 PMIMECPINFO pCodePageInfo
)
1536 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
1537 TRACE("%p, %u, %p\n", This
, uiCodePage
, pCodePageInfo
);
1539 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
1541 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
1543 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
1545 fill_cp_info(&mlang_data
[i
], n
, pCodePageInfo
);
1554 static HRESULT WINAPI
fnIMultiLanguage_GetFamilyCodePage(
1555 IMultiLanguage
* iface
,
1557 UINT
* puiFamilyCodePage
)
1559 return GetFamilyCodePage(uiCodePage
, puiFamilyCodePage
);
1562 static HRESULT WINAPI
fnIMultiLanguage_EnumCodePages(
1563 IMultiLanguage
* iface
,
1565 IEnumCodePage
** ppEnumCodePage
)
1567 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
1568 TRACE("%p %08x %p\n", This
, grfFlags
, ppEnumCodePage
);
1570 return EnumCodePage_create( This
, grfFlags
, 0, ppEnumCodePage
);
1573 static HRESULT WINAPI
fnIMultiLanguage_GetCharsetInfo(
1574 IMultiLanguage
* iface
,
1576 PMIMECSETINFO pCharsetInfo
)
1582 static HRESULT WINAPI
fnIMultiLanguage_IsConvertible(
1583 IMultiLanguage
* iface
,
1584 DWORD dwSrcEncoding
,
1585 DWORD dwDstEncoding
)
1587 return IsConvertINetStringAvailable(dwSrcEncoding
, dwDstEncoding
);
1590 static HRESULT WINAPI
fnIMultiLanguage_ConvertString(
1591 IMultiLanguage
* iface
,
1593 DWORD dwSrcEncoding
,
1594 DWORD dwDstEncoding
,
1600 return ConvertINetString(pdwMode
, dwSrcEncoding
, dwDstEncoding
,
1601 (LPCSTR
)pSrcStr
, (LPINT
)pcSrcSize
, (LPSTR
)pDstStr
, (LPINT
)pcDstSize
);
1604 static HRESULT WINAPI
fnIMultiLanguage_ConvertStringToUnicode(
1605 IMultiLanguage
* iface
,
1613 return ConvertINetMultiByteToUnicode(pdwMode
, dwEncoding
,
1614 (LPCSTR
)pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
1617 static HRESULT WINAPI
fnIMultiLanguage_ConvertStringFromUnicode(
1618 IMultiLanguage
* iface
,
1626 return ConvertINetUnicodeToMultiByte(pdwMode
, dwEncoding
,
1627 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
1630 static HRESULT WINAPI
fnIMultiLanguage_ConvertStringReset(
1631 IMultiLanguage
* iface
)
1637 static HRESULT WINAPI
fnIMultiLanguage_GetRfc1766FromLcid(
1638 IMultiLanguage
* iface
,
1642 WCHAR buf
[MAX_RFC1766_NAME
];
1644 TRACE("%p %04x %p\n", iface
, lcid
, pbstrRfc1766
);
1646 if (lcid_to_rfc1766W( lcid
, buf
, MAX_RFC1766_NAME
))
1648 *pbstrRfc1766
= SysAllocString( buf
);
1654 static HRESULT WINAPI
fnIMultiLanguage_GetLcidFromRfc1766(
1655 IMultiLanguage
* iface
,
1663 /******************************************************************************/
1665 typedef struct tagEnumRfc1766_impl
1667 const IEnumRfc1766Vtbl
*vtbl_IEnumRfc1766
;
1673 static HRESULT WINAPI
fnIEnumRfc1766_QueryInterface(
1674 IEnumRfc1766
*iface
,
1678 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
1680 TRACE("%p -> %s\n", This
, debugstr_guid(riid
) );
1682 if (IsEqualGUID(riid
, &IID_IUnknown
)
1683 || IsEqualGUID(riid
, &IID_IEnumRfc1766
))
1685 IEnumRfc1766_AddRef(iface
);
1686 TRACE("Returning IID_IEnumRfc1766 %p ref = %d\n", This
, This
->ref
);
1687 *ppvObject
= &(This
->vtbl_IEnumRfc1766
);
1691 WARN("(%p) -> (%s,%p), not found\n",This
,debugstr_guid(riid
),ppvObject
);
1692 return E_NOINTERFACE
;
1695 static ULONG WINAPI
fnIEnumRfc1766_AddRef(
1696 IEnumRfc1766
*iface
)
1698 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
1699 return InterlockedIncrement(&This
->ref
);
1702 static ULONG WINAPI
fnIEnumRfc1766_Release(
1703 IEnumRfc1766
*iface
)
1705 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
1706 ULONG ref
= InterlockedDecrement(&This
->ref
);
1708 TRACE("%p ref = %d\n", This
, ref
);
1711 TRACE("Destroying %p\n", This
);
1712 HeapFree(GetProcessHeap(), 0, This
->info
);
1713 HeapFree(GetProcessHeap(), 0, This
);
1718 static HRESULT WINAPI
fnIEnumRfc1766_Clone(
1719 IEnumRfc1766
*iface
,
1720 IEnumRfc1766
**ppEnum
)
1722 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
1723 FIXME("%p %p\n", This
, ppEnum
);
1727 static HRESULT WINAPI
fnIEnumRfc1766_Next(
1728 IEnumRfc1766
*iface
,
1731 ULONG
*pceltFetched
)
1735 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
1736 TRACE("%p %u %p %p\n", This
, celt
, rgelt
, pceltFetched
);
1738 if (!pceltFetched
) return S_FALSE
;
1741 if (!rgelt
) return S_FALSE
;
1743 if (This
->pos
+ celt
> This
->total
)
1744 celt
= This
->total
- This
->pos
;
1746 if (!celt
) return S_FALSE
;
1748 memcpy(rgelt
, This
->info
+ This
->pos
, celt
* sizeof(RFC1766INFO
));
1749 *pceltFetched
= celt
;
1752 for (i
= 0; i
< celt
; i
++)
1754 TRACE("#%u: %08x %s %s\n",
1756 wine_dbgstr_w(rgelt
[i
].wszRfc1766
),
1757 wine_dbgstr_w(rgelt
[i
].wszLocaleName
));
1762 static HRESULT WINAPI
fnIEnumRfc1766_Reset(
1763 IEnumRfc1766
*iface
)
1765 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
1766 TRACE("%p\n", This
);
1772 static HRESULT WINAPI
fnIEnumRfc1766_Skip(
1773 IEnumRfc1766
*iface
,
1776 ICOM_THIS_MULTI(EnumRfc1766_impl
, vtbl_IEnumRfc1766
, iface
);
1777 TRACE("%p %u\n", This
, celt
);
1779 if (celt
>= This
->total
) return S_FALSE
;
1785 static const IEnumRfc1766Vtbl IEnumRfc1766_vtbl
=
1787 fnIEnumRfc1766_QueryInterface
,
1788 fnIEnumRfc1766_AddRef
,
1789 fnIEnumRfc1766_Release
,
1790 fnIEnumRfc1766_Clone
,
1791 fnIEnumRfc1766_Next
,
1792 fnIEnumRfc1766_Reset
,
1796 struct enum_locales_data
1799 DWORD total
, allocated
;
1802 static BOOL CALLBACK
enum_locales_proc(LPWSTR locale
)
1805 struct enum_locales_data
*data
= TlsGetValue(MLANG_tls_index
);
1808 TRACE("%s\n", debugstr_w(locale
));
1810 if (data
->total
>= data
->allocated
)
1812 data
->allocated
+= 32;
1813 data
->info
= HeapReAlloc(GetProcessHeap(), 0, data
->info
, data
->allocated
* sizeof(RFC1766INFO
));
1814 if (!data
->info
) return FALSE
;
1817 info
= &data
->info
[data
->total
];
1819 info
->lcid
= strtolW(locale
, &end
, 16);
1820 if (*end
) /* invalid number */
1823 info
->wszRfc1766
[0] = 0;
1824 lcid_to_rfc1766W( info
->lcid
, info
->wszRfc1766
, MAX_RFC1766_NAME
);
1826 info
->wszLocaleName
[0] = 0;
1827 GetLocaleInfoW(info
->lcid
, LOCALE_SLANGUAGE
, info
->wszLocaleName
, MAX_LOCALE_NAME
);
1828 TRACE("ISO639: %s SLANGUAGE: %s\n", wine_dbgstr_w(info
->wszRfc1766
), wine_dbgstr_w(info
->wszLocaleName
));
1835 static HRESULT
EnumRfc1766_create(MLang_impl
* mlang
, LANGID LangId
,
1836 IEnumRfc1766
**ppEnum
)
1838 EnumRfc1766_impl
*rfc
;
1839 struct enum_locales_data data
;
1841 TRACE("%p, %04x, %p\n", mlang
, LangId
, ppEnum
);
1843 rfc
= HeapAlloc( GetProcessHeap(), 0, sizeof(EnumRfc1766_impl
) );
1844 rfc
->vtbl_IEnumRfc1766
= &IEnumRfc1766_vtbl
;
1850 data
.allocated
= 32;
1851 data
.info
= HeapAlloc(GetProcessHeap(), 0, data
.allocated
* sizeof(RFC1766INFO
));
1852 if (!data
.info
) return S_FALSE
;
1854 TlsSetValue(MLANG_tls_index
, &data
);
1855 EnumSystemLocalesW(enum_locales_proc
, 0/*LOCALE_SUPPORTED*/);
1856 TlsSetValue(MLANG_tls_index
, NULL
);
1858 TRACE("enumerated %d rfc1766 structures\n", data
.total
);
1860 if (!data
.total
) return FALSE
;
1862 rfc
->info
= data
.info
;
1863 rfc
->total
= data
.total
;
1865 *ppEnum
= (IEnumRfc1766
*)rfc
;
1869 static HRESULT WINAPI
fnIMultiLanguage_EnumRfc1766(
1870 IMultiLanguage
*iface
,
1871 IEnumRfc1766
**ppEnumRfc1766
)
1873 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
1874 TRACE("%p %p\n", This
, ppEnumRfc1766
);
1876 return EnumRfc1766_create(This
, 0, ppEnumRfc1766
);
1879 /******************************************************************************/
1881 static HRESULT WINAPI
fnIMultiLanguage_GetRfc1766Info(
1882 IMultiLanguage
* iface
,
1884 PRFC1766INFO pRfc1766Info
)
1890 static HRESULT WINAPI
fnIMultiLanguage_CreateConvertCharset(
1891 IMultiLanguage
* iface
,
1895 IMLangConvertCharset
** ppMLangConvertCharset
)
1901 static const IMultiLanguageVtbl IMultiLanguage_vtbl
=
1903 fnIMultiLanguage_QueryInterface
,
1904 fnIMultiLanguage_AddRef
,
1905 fnIMultiLanguage_Release
,
1906 fnIMultiLanguage_GetNumberOfCodePageInfo
,
1907 fnIMultiLanguage_GetCodePageInfo
,
1908 fnIMultiLanguage_GetFamilyCodePage
,
1909 fnIMultiLanguage_EnumCodePages
,
1910 fnIMultiLanguage_GetCharsetInfo
,
1911 fnIMultiLanguage_IsConvertible
,
1912 fnIMultiLanguage_ConvertString
,
1913 fnIMultiLanguage_ConvertStringToUnicode
,
1914 fnIMultiLanguage_ConvertStringFromUnicode
,
1915 fnIMultiLanguage_ConvertStringReset
,
1916 fnIMultiLanguage_GetRfc1766FromLcid
,
1917 fnIMultiLanguage_GetLcidFromRfc1766
,
1918 fnIMultiLanguage_EnumRfc1766
,
1919 fnIMultiLanguage_GetRfc1766Info
,
1920 fnIMultiLanguage_CreateConvertCharset
,
1924 /******************************************************************************/
1926 static HRESULT WINAPI
fnIMultiLanguage2_QueryInterface(
1927 IMultiLanguage3
* iface
,
1931 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
1932 return MLang_QueryInterface( This
, riid
, ppvObject
);
1935 static ULONG WINAPI
fnIMultiLanguage2_AddRef( IMultiLanguage3
* iface
)
1937 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
1938 return MLang_AddRef( This
);
1941 static ULONG WINAPI
fnIMultiLanguage2_Release( IMultiLanguage3
* iface
)
1943 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
1944 return MLang_Release( This
);
1947 static HRESULT WINAPI
fnIMultiLanguage2_GetNumberOfCodePageInfo(
1948 IMultiLanguage3
* iface
,
1951 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
1952 TRACE("%p, %p\n", This
, pcCodePage
);
1954 if (!pcCodePage
) return S_FALSE
;
1956 *pcCodePage
= This
->total_cp
;
1960 static void fill_cp_info(const struct mlang_data
*ml_data
, UINT index
, MIMECPINFO
*mime_cp_info
)
1964 if (TranslateCharsetInfo((DWORD
*)ml_data
->family_codepage
, &csi
, TCI_SRCCODEPAGE
))
1965 mime_cp_info
->bGDICharset
= csi
.ciCharset
;
1967 mime_cp_info
->bGDICharset
= DEFAULT_CHARSET
;
1969 mime_cp_info
->dwFlags
= ml_data
->mime_cp_info
[index
].flags
;
1970 mime_cp_info
->uiCodePage
= ml_data
->mime_cp_info
[index
].cp
;
1971 mime_cp_info
->uiFamilyCodePage
= ml_data
->family_codepage
;
1972 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].description
, -1,
1973 mime_cp_info
->wszDescription
, sizeof(mime_cp_info
->wszDescription
)/sizeof(WCHAR
));
1974 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].web_charset
, -1,
1975 mime_cp_info
->wszWebCharset
, sizeof(mime_cp_info
->wszWebCharset
)/sizeof(WCHAR
));
1976 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].header_charset
, -1,
1977 mime_cp_info
->wszHeaderCharset
, sizeof(mime_cp_info
->wszHeaderCharset
)/sizeof(WCHAR
));
1978 MultiByteToWideChar(CP_ACP
, 0, ml_data
->mime_cp_info
[index
].body_charset
, -1,
1979 mime_cp_info
->wszBodyCharset
, sizeof(mime_cp_info
->wszBodyCharset
)/sizeof(WCHAR
));
1981 MultiByteToWideChar(CP_ACP
, 0, ml_data
->fixed_font
, -1,
1982 mime_cp_info
->wszFixedWidthFont
, sizeof(mime_cp_info
->wszFixedWidthFont
)/sizeof(WCHAR
));
1983 MultiByteToWideChar(CP_ACP
, 0, ml_data
->proportional_font
, -1,
1984 mime_cp_info
->wszProportionalFont
, sizeof(mime_cp_info
->wszProportionalFont
)/sizeof(WCHAR
));
1986 TRACE("%08x %u %u %s %s %s %s %s %s %d\n",
1987 mime_cp_info
->dwFlags
, mime_cp_info
->uiCodePage
,
1988 mime_cp_info
->uiFamilyCodePage
,
1989 wine_dbgstr_w(mime_cp_info
->wszDescription
),
1990 wine_dbgstr_w(mime_cp_info
->wszWebCharset
),
1991 wine_dbgstr_w(mime_cp_info
->wszHeaderCharset
),
1992 wine_dbgstr_w(mime_cp_info
->wszBodyCharset
),
1993 wine_dbgstr_w(mime_cp_info
->wszFixedWidthFont
),
1994 wine_dbgstr_w(mime_cp_info
->wszProportionalFont
),
1995 mime_cp_info
->bGDICharset
);
1998 static HRESULT WINAPI
fnIMultiLanguage2_GetCodePageInfo(
1999 IMultiLanguage3
* iface
,
2002 PMIMECPINFO pCodePageInfo
)
2006 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2007 TRACE("%p, %u, %04x, %p\n", This
, uiCodePage
, LangId
, pCodePageInfo
);
2009 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2011 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2013 if (mlang_data
[i
].mime_cp_info
[n
].cp
== uiCodePage
)
2015 fill_cp_info(&mlang_data
[i
], n
, pCodePageInfo
);
2024 static HRESULT WINAPI
fnIMultiLanguage2_GetFamilyCodePage(
2025 IMultiLanguage3
* iface
,
2027 UINT
* puiFamilyCodePage
)
2029 return GetFamilyCodePage(uiCodePage
, puiFamilyCodePage
);
2032 static HRESULT WINAPI
fnIMultiLanguage2_EnumCodePages(
2033 IMultiLanguage3
* iface
,
2036 IEnumCodePage
** ppEnumCodePage
)
2038 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2039 TRACE("%p %08x %04x %p\n", This
, grfFlags
, LangId
, ppEnumCodePage
);
2041 return EnumCodePage_create( This
, grfFlags
, LangId
, ppEnumCodePage
);
2044 static HRESULT WINAPI
fnIMultiLanguage2_GetCharsetInfo(
2045 IMultiLanguage3
* iface
,
2047 PMIMECSETINFO pCharsetInfo
)
2051 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2052 TRACE("%p %s %p\n", This
, debugstr_w(Charset
), pCharsetInfo
);
2054 if (!pCharsetInfo
) return E_FAIL
;
2056 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2058 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2060 WCHAR csetW
[MAX_MIMECSET_NAME
];
2062 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].mime_cp_info
[n
].web_charset
, -1, csetW
, MAX_MIMECSET_NAME
);
2063 if (!lstrcmpiW(Charset
, csetW
))
2065 pCharsetInfo
->uiCodePage
= mlang_data
[i
].family_codepage
;
2066 pCharsetInfo
->uiInternetEncoding
= mlang_data
[i
].mime_cp_info
[n
].cp
;
2067 strcpyW(pCharsetInfo
->wszCharset
, csetW
);
2074 * Since we do not support charsets like iso-2022-jp and do not have
2075 * them in our database as a primary (web_charset) encoding this loop
2076 * does an attempt to 'approximate' charset name by header_charset.
2078 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2080 for (n
= 0; n
< mlang_data
[i
].number_of_cp
; n
++)
2082 WCHAR csetW
[MAX_MIMECSET_NAME
];
2084 MultiByteToWideChar(CP_ACP
, 0, mlang_data
[i
].mime_cp_info
[n
].header_charset
, -1, csetW
, MAX_MIMECSET_NAME
);
2085 if (!lstrcmpiW(Charset
, csetW
))
2087 pCharsetInfo
->uiCodePage
= mlang_data
[i
].family_codepage
;
2088 pCharsetInfo
->uiInternetEncoding
= mlang_data
[i
].mime_cp_info
[n
].cp
;
2089 strcpyW(pCharsetInfo
->wszCharset
, csetW
);
2098 static HRESULT WINAPI
fnIMultiLanguage2_IsConvertible(
2099 IMultiLanguage3
* iface
,
2100 DWORD dwSrcEncoding
,
2101 DWORD dwDstEncoding
)
2103 return IsConvertINetStringAvailable(dwSrcEncoding
, dwDstEncoding
);
2106 static HRESULT WINAPI
fnIMultiLanguage2_ConvertString(
2107 IMultiLanguage3
* iface
,
2109 DWORD dwSrcEncoding
,
2110 DWORD dwDstEncoding
,
2116 return ConvertINetString(pdwMode
, dwSrcEncoding
, dwDstEncoding
,
2117 (LPCSTR
)pSrcStr
, (LPINT
)pcSrcSize
, (LPSTR
)pDstStr
, (LPINT
)pcDstSize
);
2120 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringToUnicode(
2121 IMultiLanguage3
* iface
,
2129 return ConvertINetMultiByteToUnicode(pdwMode
, dwEncoding
,
2130 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2133 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringFromUnicode(
2134 IMultiLanguage3
* iface
,
2142 return ConvertINetUnicodeToMultiByte(pdwMode
, dwEncoding
,
2143 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2146 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringReset(
2147 IMultiLanguage3
* iface
)
2153 static HRESULT WINAPI
fnIMultiLanguage2_GetRfc1766FromLcid(
2154 IMultiLanguage3
* iface
,
2158 WCHAR buf
[MAX_RFC1766_NAME
];
2160 TRACE("%p %04x %p\n", iface
, lcid
, pbstrRfc1766
);
2162 if (lcid_to_rfc1766W( lcid
, buf
, MAX_RFC1766_NAME
))
2164 *pbstrRfc1766
= SysAllocString( buf
);
2170 static HRESULT WINAPI
fnIMultiLanguage2_GetLcidFromRfc1766(
2171 IMultiLanguage3
* iface
,
2179 static HRESULT WINAPI
fnIMultiLanguage2_EnumRfc1766(
2180 IMultiLanguage3
* iface
,
2182 IEnumRfc1766
** ppEnumRfc1766
)
2184 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage
, iface
);
2185 TRACE("%p %p\n", This
, ppEnumRfc1766
);
2187 return EnumRfc1766_create(This
, LangId
, ppEnumRfc1766
);
2190 static HRESULT WINAPI
fnIMultiLanguage2_GetRfc1766Info(
2191 IMultiLanguage3
* iface
,
2194 PRFC1766INFO pRfc1766Info
)
2200 static HRESULT WINAPI
fnIMultiLanguage2_CreateConvertCharset(
2201 IMultiLanguage3
* iface
,
2205 IMLangConvertCharset
** ppMLangConvertCharset
)
2211 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringInIStream(
2212 IMultiLanguage3
* iface
,
2216 DWORD dwSrcEncoding
,
2217 DWORD dwDstEncoding
,
2226 * TODO: handle dwFlag and lpFallBack
2228 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringToUnicodeEx(
2229 IMultiLanguage3
* iface
,
2240 return ConvertINetMultiByteToUnicode(pdwMode
, dwEncoding
,
2241 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2244 /*****************************************************************************
2245 * MultiLanguage2::ConvertStringToUnicodeEx
2247 * Translates the multibyte string from the specified code page to Unicode.
2250 * see ConvertStringToUnicode
2252 * lpFallBack if dwFlag contains MLCONVCHARF_USEDEFCHAR, lpFallBack string used
2253 * instead unconvertible characters.
2257 * S_FALSE The conversion is not supported.
2258 * E_FAIL Some error has occurred.
2260 * TODO: handle dwFlag and lpFallBack
2262 static HRESULT WINAPI
fnIMultiLanguage2_ConvertStringFromUnicodeEx(
2263 IMultiLanguage3
* This
,
2274 return ConvertINetUnicodeToMultiByte(pdwMode
, dwEncoding
,
2275 pSrcStr
, (LPINT
)pcSrcSize
, pDstStr
, (LPINT
)pcDstSize
);
2278 static HRESULT WINAPI
fnIMultiLanguage2_DetectCodepageInIStream(
2279 IMultiLanguage3
* iface
,
2281 DWORD dwPrefWinCodePage
,
2283 DetectEncodingInfo
* lpEncoding
,
2290 static HRESULT WINAPI
fnIMultiLanguage2_DetectInputCodepage(
2291 IMultiLanguage3
* iface
,
2293 DWORD dwPrefWinCodePage
,
2296 DetectEncodingInfo
* lpEncoding
,
2303 static HRESULT WINAPI
fnIMultiLanguage2_ValidateCodePage(
2304 IMultiLanguage3
* iface
,
2308 FIXME("%u, %p\n", uiCodePage
, hwnd
);
2312 static HRESULT WINAPI
fnIMultiLanguage2_GetCodePageDescription(
2313 IMultiLanguage3
* iface
,
2316 LPWSTR lpWideCharStr
,
2319 FIXME("%u, %04x, %p, %d\n", uiCodePage
, lcid
, lpWideCharStr
, cchWideChar
);
2323 static HRESULT WINAPI
fnIMultiLanguage2_IsCodePageInstallable(
2324 IMultiLanguage3
* iface
,
2327 FIXME("%u\n", uiCodePage
);
2331 static HRESULT WINAPI
fnIMultiLanguage2_SetMimeDBSource(
2332 IMultiLanguage3
* iface
,
2335 FIXME("0x%08x\n", dwSource
);
2339 static HRESULT WINAPI
fnIMultiLanguage2_GetNumberOfScripts(
2340 IMultiLanguage3
* iface
,
2343 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2344 TRACE("%p %p\n", This
, pnScripts
);
2346 if (!pnScripts
) return S_FALSE
;
2348 *pnScripts
= This
->total_scripts
;
2352 static HRESULT WINAPI
fnIMultiLanguage2_EnumScripts(
2353 IMultiLanguage3
* iface
,
2356 IEnumScript
** ppEnumScript
)
2358 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2359 TRACE("%p %08x %04x %p\n", This
, dwFlags
, LangId
, ppEnumScript
);
2361 return EnumScript_create( This
, dwFlags
, LangId
, ppEnumScript
);
2364 static HRESULT WINAPI
fnIMultiLanguage2_ValidateCodePageEx(
2365 IMultiLanguage3
* iface
,
2368 DWORD dwfIODControl
)
2370 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2371 FIXME("%p %u %p %08x: stub!\n", This
, uiCodePage
, hwnd
, dwfIODControl
);
2376 static HRESULT WINAPI
fnIMultiLanguage3_DetectOutboundCodePage(
2377 IMultiLanguage3
*iface
,
2379 LPCWSTR lpWideCharStr
,
2381 UINT
*puiPreferredCodePages
,
2382 UINT nPreferredCodePages
,
2383 UINT
*puiDetectedCodePages
,
2384 UINT
*pnDetectedCodePages
,
2385 WCHAR
*lpSpecialChar
)
2387 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2388 FIXME("(%p)->(%08x %s %u %p %u %p %p %p)\n", This
, dwFlags
, debugstr_w(lpWideCharStr
),
2389 cchWideChar
, puiPreferredCodePages
, nPreferredCodePages
, puiDetectedCodePages
,
2390 pnDetectedCodePages
, lpSpecialChar
);
2394 static HRESULT WINAPI
fnIMultiLanguage3_DetectOutboundCodePageInIStream(
2395 IMultiLanguage3
*iface
,
2398 UINT
*puiPreferredCodePages
,
2399 UINT nPreferredCodePages
,
2400 UINT
*puiDetectedCodePages
,
2401 UINT
*pnDetectedCodePages
,
2402 WCHAR
*lpSpecialChar
)
2404 ICOM_THIS_MULTI(MLang_impl
, vtbl_IMultiLanguage3
, iface
);
2405 FIXME("(%p)->(%08x %p %p %u %p %p %p)\n", This
, dwFlags
, pStrIn
,
2406 puiPreferredCodePages
, nPreferredCodePages
, puiDetectedCodePages
,
2407 pnDetectedCodePages
, lpSpecialChar
);
2411 static const IMultiLanguage3Vtbl IMultiLanguage3_vtbl
=
2413 fnIMultiLanguage2_QueryInterface
,
2414 fnIMultiLanguage2_AddRef
,
2415 fnIMultiLanguage2_Release
,
2416 fnIMultiLanguage2_GetNumberOfCodePageInfo
,
2417 fnIMultiLanguage2_GetCodePageInfo
,
2418 fnIMultiLanguage2_GetFamilyCodePage
,
2419 fnIMultiLanguage2_EnumCodePages
,
2420 fnIMultiLanguage2_GetCharsetInfo
,
2421 fnIMultiLanguage2_IsConvertible
,
2422 fnIMultiLanguage2_ConvertString
,
2423 fnIMultiLanguage2_ConvertStringToUnicode
,
2424 fnIMultiLanguage2_ConvertStringFromUnicode
,
2425 fnIMultiLanguage2_ConvertStringReset
,
2426 fnIMultiLanguage2_GetRfc1766FromLcid
,
2427 fnIMultiLanguage2_GetLcidFromRfc1766
,
2428 fnIMultiLanguage2_EnumRfc1766
,
2429 fnIMultiLanguage2_GetRfc1766Info
,
2430 fnIMultiLanguage2_CreateConvertCharset
,
2431 fnIMultiLanguage2_ConvertStringInIStream
,
2432 fnIMultiLanguage2_ConvertStringToUnicodeEx
,
2433 fnIMultiLanguage2_ConvertStringFromUnicodeEx
,
2434 fnIMultiLanguage2_DetectCodepageInIStream
,
2435 fnIMultiLanguage2_DetectInputCodepage
,
2436 fnIMultiLanguage2_ValidateCodePage
,
2437 fnIMultiLanguage2_GetCodePageDescription
,
2438 fnIMultiLanguage2_IsCodePageInstallable
,
2439 fnIMultiLanguage2_SetMimeDBSource
,
2440 fnIMultiLanguage2_GetNumberOfScripts
,
2441 fnIMultiLanguage2_EnumScripts
,
2442 fnIMultiLanguage2_ValidateCodePageEx
,
2443 fnIMultiLanguage3_DetectOutboundCodePage
,
2444 fnIMultiLanguage3_DetectOutboundCodePageInIStream
2447 static HRESULT
MultiLanguage_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
2452 TRACE("Creating MultiLanguage object\n");
2455 return CLASS_E_NOAGGREGATION
;
2457 mlang
= HeapAlloc( GetProcessHeap(), 0, sizeof (MLang_impl
) );
2458 mlang
->vtbl_IMLangFontLink
= &IMLangFontLink_vtbl
;
2459 mlang
->vtbl_IMultiLanguage
= &IMultiLanguage_vtbl
;
2460 mlang
->vtbl_IMultiLanguage3
= &IMultiLanguage3_vtbl
;
2462 mlang
->total_cp
= 0;
2463 for (i
= 0; i
< sizeof(mlang_data
)/sizeof(mlang_data
[0]); i
++)
2464 mlang
->total_cp
+= mlang_data
[i
].number_of_cp
;
2466 /* do not enumerate unicode flavours */
2467 mlang
->total_scripts
= sizeof(mlang_data
)/sizeof(mlang_data
[0]) - 1;
2470 *ppObj
= (LPVOID
) mlang
;
2471 TRACE("returning %p\n", mlang
);
2478 /******************************************************************************/
2480 HRESULT WINAPI
DllCanUnloadNow(void)
2482 return dll_count
== 0 ? S_OK
: S_FALSE
;
2485 HRESULT WINAPI
GetGlobalFontLinkObject(void)