netapi32: Remove DECLSPEC_HIDDEN usage.
[wine.git] / dlls / mlang / tests / mlang.c
blob3240d945245f778d4644ccc2e1d6f942aad88fe8
1 /*
2 * Unit test suite for MLANG APIs.
4 * Copyright 2004 Dmitry Timoshkov
5 * Copyright 2009 Detlef Riekenberg
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define COBJMACROS
24 #include <stdarg.h>
25 #include <stdio.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winerror.h"
30 #include "initguid.h"
31 #include "mlang.h"
33 #include "wine/test.h"
35 #ifndef CP_UNICODE
36 #define CP_UNICODE 1200
37 #endif
39 /* #define DUMP_CP_INFO */
40 /* #define DUMP_SCRIPT_INFO */
42 static BOOL (WINAPI *pGetCPInfoExA)(UINT, DWORD, LPCPINFOEXA);
43 static HRESULT (WINAPI *pConvertINetMultiByteToUnicode)(LPDWORD, DWORD, LPCSTR,
44 LPINT, LPWSTR, LPINT);
45 static HRESULT (WINAPI *pConvertINetUnicodeToMultiByte)(LPDWORD, DWORD, LPCWSTR,
46 LPINT, LPSTR, LPINT);
47 static HRESULT (WINAPI *pRfc1766ToLcidA)(LCID *, LPCSTR);
48 static HRESULT (WINAPI *pLcidToRfc1766A)(LCID, LPSTR, INT);
50 typedef struct lcid_tag_table {
51 LPCSTR rfc1766;
52 LCID lcid;
53 HRESULT hr;
54 LCID broken_lcid;
55 LPCSTR broken_rfc;
56 } lcid_table_entry;
58 /* en, ar and zh use SUBLANG_NEUTRAL for the rfc1766 name without the country
59 all others suppress the country with SUBLANG_DEFAULT.
60 For 3 letter language codes, the rfc1766 is too small for the country */
62 static const lcid_table_entry lcid_table[] = {
63 {"e", -1, E_FAIL},
64 {"", -1, E_FAIL},
65 {"-", -1, E_FAIL},
66 {"e-", -1, E_FAIL},
68 {"ar", 1, S_OK},
69 {"zh", 4, S_OK},
71 {"de", 0x0407, S_OK},
72 {"de-ch", 0x0807, S_OK},
73 {"de-at", 0x0c07, S_OK},
74 {"de-lu", 0x1007, S_OK},
75 {"de-li", 0x1407, S_OK},
77 {"en", 9, S_OK},
78 {"en-gb", 0x809, S_OK},
79 {"en-GB", 0x809, S_OK},
80 {"EN-GB", 0x809, S_OK},
81 {"en-US", 0x409, S_OK},
82 {"en-us", 0x409, S_OK},
84 {"fr", 0x040c, S_OK},
85 {"fr-be", 0x080c, S_OK},
86 {"fr-ca", 0x0c0c, S_OK},
87 {"fr-ch", 0x100c, S_OK},
88 {"fr-lu", 0x140c, S_OK},
89 {"fr-mc", 0x180c, S_OK, 0x040c, "fr"},
91 {"it", 0x0410, S_OK},
92 {"it-ch", 0x0810, S_OK},
94 {"nl", 0x0413, S_OK},
95 {"nl-be", 0x0813, S_OK},
96 {"pl", 0x0415, S_OK},
97 {"ru", 0x0419, S_OK},
99 {"kok", 0x0457, S_OK, 0x0412, "x-kok"}
103 #define TODO_NAME 1
105 typedef struct info_table_tag {
106 LCID lcid;
107 LANGID lang;
108 DWORD todo;
109 LPCSTR rfc1766;
110 LPCWSTR localename;
111 LPCWSTR broken_name;
112 } info_table_entry;
114 static const WCHAR de_en[] = {'E','n','g','l','i','s','c','h',0};
115 static const WCHAR de_enca[] = {'E','n','g','l','i','s','c','h',' ',
116 '(','K','a','n','a','d','a',')',0};
117 static const WCHAR de_engb[] = {'E','n','g','l','i','s','c','h',' ',
118 '(','G','r','o',0xDF,'b','r','i','t','a','n','n','i','e','n',')',0};
119 static const WCHAR de_engb2[] ={'E','n','g','l','i','s','c','h',' ',
120 '(','V','e','r','e','i','n','i','g','t','e','s',' ',
121 'K',0xF6,'n','i','g','r','e','i','c',0};
122 static const WCHAR de_enus[] = {'E','n','g','l','i','s','c','h',' ',
123 '(','U','S','A',')',0};
124 static const WCHAR de_enus2[] ={'E','n','g','l','i','s','c','h',' ',
125 '(','V','e','r','e','i','n','i','g','t','e',' ',
126 'S','t','a','a','t','e','n',')',0};
127 static const WCHAR de_de[] = {'D','e','u','t','s','c','h',' ',
128 '(','D','e','u','t','s','c','h','l','a','n','d',')',0};
129 static const WCHAR de_deat[] = {'D','e','u','t','s','c','h',' ',
130 '(',0xD6,'s','t','e','r','r','e','i','c','h',')',0};
131 static const WCHAR de_dech[] = {'D','e','u','t','s','c','h',' ',
132 '(','S','c','h','w','e','i','z',')',0};
134 static const WCHAR en_en[] = {'E','n','g','l','i','s','h',0};
135 static const WCHAR en_enca[] = {'E','n','g','l','i','s','h',' ',
136 '(','C','a','n','a','d','a',')',0};
137 static const WCHAR en_engb[] = {'E','n','g','l','i','s','h',' ',
138 '(','U','n','i','t','e','d',' ','K','i','n','g','d','o','m',')',0};
139 static const WCHAR en_enus[] = {'E','n','g','l','i','s','h',' ',
140 '(','U','n','i','t','e','d',' ','S','t','a','t','e','s',')',0};
141 static const WCHAR en_de[] = {'G','e','r','m','a','n',' ',
142 '(','G','e','r','m','a','n','y',')',0};
143 static const WCHAR en_deat[] = {'G','e','r','m','a','n',' ',
144 '(','A','u','s','t','r','i','a',')',0};
145 static const WCHAR en_dech[] = {'G','e','r','m','a','n',' ',
146 '(','S','w','i','t','z','e','r','l','a','n','d',')',0};
148 static const WCHAR fr_en[] = {'A','n','g','l','a','i','s',0};
149 static const WCHAR fr_enca[] = {'A','n','g','l','a','i','s',' ',
150 '(','C','a','n','a','d','a',')',0};
151 static const WCHAR fr_engb[] = {'A','n','g','l','a','i','s',' ',
152 '(','R','o','y','a','u','m','e','-','U','n','i',')',0};
153 static const WCHAR fr_enus[] = {'A','n','g','l','a','i','s',' ',
154 '(',0xC9, 't','a','t','s','-','U','n','i','s',')',0};
155 static const WCHAR fr_enus2[] ={'A','n','g','l','a','i','s',' ',
156 '(','U','.','S','.',')',0};
157 static const WCHAR fr_de[] = {'A','l','l','e','m','a','n','d',' ',
158 '(','A','l','l','e','m','a','g','n','e',')',0};
159 static const WCHAR fr_de2[] = {'A','l','l','e','m','a','n','d',' ',
160 '(','S','t','a','n','d','a','r','d',')',0};
161 static const WCHAR fr_deat[] = {'A','l','l','e','m','a','n','d',' ',
162 '(','A','u','t','r','i','c','h','e',')',0};
163 static const WCHAR fr_dech[] = {'A','l','l','e','m','a','n','d',' ',
164 '(','S','u','i','s','s','e',')',0};
166 static const info_table_entry info_table[] = {
167 {MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL), MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL),
168 0, "en", en_en},
169 {MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL),
170 0, "en-us", en_enus},
171 {MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_UK), MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL),
172 0, "en-gb", en_engb},
173 {MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL),
174 0, "en-us", en_enus},
175 {MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_CAN), MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL),
176 0, "en-ca", en_enca},
178 {MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL),
179 0, "de", en_de},
180 {MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL),
181 0, "de", en_de},
182 {MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN_SWISS), MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL),
183 0, "de-ch", en_dech},
184 {MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN_AUSTRIAN), MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL),
185 0, "de-at", en_deat},
187 {MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL), MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT),
188 TODO_NAME, "en", de_en},
189 {MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT),
190 TODO_NAME, "en-us", de_enus, de_enus2},
191 {MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_UK), MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT),
192 TODO_NAME, "en-gb", de_engb, de_engb2},
193 {MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT),
194 TODO_NAME, "en-us", de_enus, de_enus2},
195 {MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_CAN), MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT),
196 TODO_NAME, "en-ca", de_enca},
198 {MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT),
199 TODO_NAME, "de", de_de},
200 {MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT),
201 TODO_NAME, "de",de_de},
202 {MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN_SWISS), MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT),
203 TODO_NAME, "de-ch", de_dech},
204 {MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN_AUSTRIAN), MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT),
205 TODO_NAME, "de-at", de_deat},
207 {MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL), MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT),
208 TODO_NAME, "en", fr_en},
209 {MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT),
210 TODO_NAME, "en-us", fr_enus, fr_enus2},
211 {MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_UK), MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT),
212 TODO_NAME, "en-gb", fr_engb},
213 {MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT),
214 TODO_NAME, "en-us", fr_enus, fr_enus2},
215 {MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_CAN), MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT),
216 TODO_NAME, "en-ca", fr_enca},
218 {MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT),
219 TODO_NAME, "de", fr_de, fr_de2},
220 {MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT),
221 TODO_NAME, "de", fr_de, fr_de2},
222 {MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN_SWISS), MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT),
223 TODO_NAME, "de-ch", fr_dech},
224 {MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN_AUSTRIAN), MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT),
225 TODO_NAME, "de-at", fr_deat}
229 struct cpinfo_test_data
231 MIMECPINFO cpinfo;
233 BOOL todo_GetCodePageInfo;
234 BOOL todo_dwFlags;
235 BOOL todo_uiFamilyCodePage;
236 BOOL todo_wszDescription;
237 BOOL todo_wszWebCharset;
238 BOOL todo_wszHeaderCharset;
239 BOOL todo_wszBodyCharset;
240 BOOL todo_wszFixedWidthFont;
241 BOOL todo_wszProportionalFont;
244 const static struct cpinfo_test_data iml2_cpinfo_data[] =
246 /* 0. Chinese Simplified (Auto-Select) */
249 MIMECONTF_IMPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
250 50936, 936, {'C','h','i','n','e','s','e',' ','S','i','m','p','l','i','f','i','e','d',' ','(','A','u','t','o','-','S','e','l','e','c','t',')',0},
251 {'_','a','u','t','o','d','e','t','e','c','t','_','c','h','s',0},
252 {'_','a','u','t','o','d','e','t','e','c','t','_','c','h','s',0},
253 {'_','a','u','t','o','d','e','t','e','c','t','_','c','h','s',0},
254 {'S','i','m','s','u','n',0},
255 {'S','i','m','s','u','n',0}, 134
258 /* 1. Chinese Simplified (GB2312) */
261 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
262 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
263 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
264 936, 936, {'C','h','i','n','e','s','e',' ','S','i','m','p','l','i','f','i','e','d',' ','(','G','B','2','3','1','2',')',0},
265 {'g','b','2','3','1','2',0},
266 {'g','b','2','3','1','2',0},
267 {'g','b','2','3','1','2',0},
268 {'S','i','m','s','u','n',0},
269 {'S','i','m','s','u','n',0}, 134
272 /* 2. Chinese Simplified (GB2312-80) */
275 MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
276 MIMECONTF_MIME_LATEST,
277 20936, 936, {'C','h','i','n','e','s','e',' ','S','i','m','p','l','i','f','i','e','d',' ','(','G','B','2','3','1','2','-','8','0',')',0},
278 {'x','-','c','p','2','0','9','3','6',0},
279 {'x','-','c','p','2','0','9','3','6',0},
280 {'x','-','c','p','2','0','9','3','6',0},
281 {'S','i','m','s','u','n',0},
282 {'S','i','m','s','u','n',0}, 134
285 /* 3. Chinese Simplified (HZ) */
288 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
289 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
290 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
291 52936, 936, {'C','h','i','n','e','s','e',' ','S','i','m','p','l','i','f','i','e','d',' ','(','H','Z',')',0},
292 {'h','z','-','g','b','-','2','3','1','2',0},
293 {'h','z','-','g','b','-','2','3','1','2',0},
294 {'h','z','-','g','b','-','2','3','1','2',0},
295 {'S','i','m','s','u','n',0},
296 {'S','i','m','s','u','n',0}, 134
299 /* 4. Chinese Simplified (GB18030) */
302 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
303 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
304 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
305 54936, 936, {'C','h','i','n','e','s','e',' ','S','i','m','p','l','i','f','i','e','d',' ','(','G','B','1','8','0','3','0',')',0},
306 {'G','B','1','8','0','3','0',0},
307 {'G','B','1','8','0','3','0',0},
308 {'G','B','1','8','0','3','0',0},
309 {'S','i','m','s','u','n',0},
310 {'S','i','m','s','u','n',0}, 134
313 /* 5. Chinese Traditional (Auto-Select) */
316 MIMECONTF_IMPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
317 50950, 950, {'C','h','i','n','e','s','e',' ','T','r','a','d','i','t','i','o','n','a','l',' ','(','A','u','t','o','-','S','e','l','e','c','t',')',0},
318 {'_','a','u','t','o','d','e','t','e','c','t','_','c','h','t',0},
319 {'_','a','u','t','o','d','e','t','e','c','t','_','c','h','t',0},
320 {'_','a','u','t','o','d','e','t','e','c','t','_','c','h','t',0},
321 {'M','i','n','g','L','i','u',0},
322 {'N','e','w',' ','M','i','n','g','L','i','u',0}, 136
325 /* 6. Chinese Traditional (Big5) */
328 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
329 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
330 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
331 950, 950, {'C','h','i','n','e','s','e',' ','T','r','a','d','i','t','i','o','n','a','l',' ','(','B','i','g','5',')',0},
332 {'b','i','g','5',0},
333 {'b','i','g','5',0},
334 {'b','i','g','5',0},
335 {'M','i','n','g','L','i','u',0},
336 {'N','e','w',' ','M','i','n','g','L','i','u',0}, 136
339 /* 7. Chinese Traditional (CNS) */
342 MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
343 MIMECONTF_MIME_LATEST,
344 20000, 950, {'C','h','i','n','e','s','e',' ','T','r','a','d','i','t','i','o','n','a','l',' ','(','C','N','S',')',0},
345 {'x','-','C','h','i','n','e','s','e','-','C','N','S',0},
346 {'x','-','C','h','i','n','e','s','e','-','C','N','S',0},
347 {'x','-','C','h','i','n','e','s','e','-','C','N','S',0},
348 {'M','i','n','g','L','i','u',0},
349 {'N','e','w',' ','M','i','n','g','L','i','u',0}, 136
352 /* 8. Arabic (Windows) */
355 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
356 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
357 MIMECONTF_MIME_LATEST,
358 1256, 1256, {'A','r','a','b','i','c',' ','(','W','i','n','d','o','w','s',')',0},
359 {'w','i','n','d','o','w','s','-','1','2','5','6',0},
360 {'w','i','n','d','o','w','s','-','1','2','5','6',0},
361 {'w','i','n','d','o','w','s','-','1','2','5','6',0},
362 {'S','i','m','p','l','i','f','i','e','d',' ','A','r','a','b','i','c',' ','F','i','x','e','d',0},
363 {'S','i','m','p','l','i','f','i','e','d',' ','A','r','a','b','i','c',0}, 178
366 /* 9. Baltic (Windows) */
369 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
370 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
371 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
372 1257, 1257, {'B','a','l','t','i','c',' ','(','W','i','n','d','o','w','s',')',0},
373 {'w','i','n','d','o','w','s','-','1','2','5','7',0},
374 {'w','i','n','d','o','w','s','-','1','2','5','7',0},
375 {'w','i','n','d','o','w','s','-','1','2','5','7',0},
376 {'C','o','u','r','i','e','r',' ','N','e','w',0},
377 {'A','r','i','a','l',0}, 186
380 /* 10. Central European (Windows) */
383 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
384 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
385 MIMECONTF_MIME_LATEST,
386 1250, 1250, {'C','e','n','t','r','a','l',' ','E','u','r','o','p','e','a','n',' ','(','W','i','n','d','o','w','s',')',0},
387 {'w','i','n','d','o','w','s','-','1','2','5','0',0},
388 {'w','i','n','d','o','w','s','-','1','2','5','0',0},
389 {'i','s','o','-','8','8','5','9','-','2',0},
390 {'C','o','u','r','i','e','r',' ','N','e','w',0},
391 {'A','r','i','a','l',0}, 238
393 FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE
395 /* 11. Cyrillic (Windows) */
398 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
399 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
400 MIMECONTF_MIME_LATEST,
401 1251, 1251, {'C','y','r','i','l','l','i','c',' ','(','W','i','n','d','o','w','s',')',0},
402 {'w','i','n','d','o','w','s','-','1','2','5','1',0},
403 {'w','i','n','d','o','w','s','-','1','2','5','1',0},
404 {'k','o','i','8','-','r',0},
405 {'C','o','u','r','i','e','r',' ','N','e','w',0},
406 {'A','r','i','a','l',0}, 204
408 FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE
410 /* 12. Greek (Windows) */
413 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
414 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
415 MIMECONTF_MIME_LATEST,
416 1253, 1253, {'G','r','e','e','k',' ','(','W','i','n','d','o','w','s',')',0},
417 {'w','i','n','d','o','w','s','-','1','2','5','3',0},
418 {'w','i','n','d','o','w','s','-','1','2','5','3',0},
419 {'i','s','o','-','8','8','5','9','-','7',0},
420 {'C','o','u','r','i','e','r',' ','N','e','w',0},
421 {'A','r','i','a','l',0}, 161
423 FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE
425 /* 13. Hebrew (Windows) */
428 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
429 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
430 MIMECONTF_MIME_LATEST,
431 1255, 1255, {'H','e','b','r','e','w',' ','(','W','i','n','d','o','w','s',')',0},
432 {'w','i','n','d','o','w','s','-','1','2','5','5',0},
433 {'w','i','n','d','o','w','s','-','1','2','5','5',0},
434 {'w','i','n','d','o','w','s','-','1','2','5','5',0},
435 {'M','i','r','i','a','m',' ','F','i','x','e','d',0},
436 {'D','a','v','i','d',0}, 177
439 /* 14. Japanese (Shift-JIS) */
442 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
443 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
444 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
445 932, 932, {'J','a','p','a','n','e','s','e',' ','(','S','h','i','f','t','-','J','I','S',')',0},
446 {'s','h','i','f','t','_','j','i','s',0},
447 {'i','s','o','-','2','0','2','2','-','j','p',0},
448 {'i','s','o','-','2','0','2','2','-','j','p',0},
449 {'M','S',' ','G','o','t','h','i','c',0},
450 {'M','S',' ','P','G','o','t','h','i','c',0}, 128
453 /* 15. Korean */
456 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
457 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
458 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
459 949, 949, {'K','o','r','e','a','n',0},
460 {'k','s','_','c','_','5','6','0','1','-','1','9','8','7',0},
461 {'k','s','_','c','_','5','6','0','1','-','1','9','8','7',0},
462 {'k','s','_','c','_','5','6','0','1','-','1','9','8','7',0},
463 {'G','u','l','i','m','C','h','e',0},
464 {'G','u','l','i','m',0}, 129
467 /* 16. Thai (Windows) */
470 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
471 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
472 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
473 874, 874, {'T','h','a','i',' ','(','W','i','n','d','o','w','s',')',0},
474 {'w','i','n','d','o','w','s','-','8','7','4',0},
475 {'w','i','n','d','o','w','s','-','8','7','4',0},
476 {'w','i','n','d','o','w','s','-','8','7','4',0},
477 {'T','a','h','o','m','a',0},
478 {'T','a','h','o','m','a',0}, 222
480 FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE
482 /* 17. Turkish (Windows) */
485 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
486 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
487 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
488 1254, 1254, {'T','u','r','k','i','s','h',' ','(','W','i','n','d','o','w','s',')',0},
489 {'w','i','n','d','o','w','s','-','1','2','5','4',0},
490 {'w','i','n','d','o','w','s','-','1','2','5','4',0},
491 {'i','s','o','-','8','8','5','9','-','9',0},
492 {'C','o','u','r','i','e','r',' ','N','e','w',0},
493 {'A','r','i','a','l',0}, 162
495 FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE
497 /* 18. Vietnamese (Windows) */
500 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
501 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
502 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
503 1258, 1258, {'V','i','e','t','n','a','m','e','s','e',' ','(','W','i','n','d','o','w','s',')',0},
504 {'w','i','n','d','o','w','s','-','1','2','5','8',0},
505 {'w','i','n','d','o','w','s','-','1','2','5','8',0},
506 {'w','i','n','d','o','w','s','-','1','2','5','8',0},
507 {'C','o','u','r','i','e','r',' ','N','e','w',0},
508 {'A','r','i','a','l',0}, 163
511 /* 19. Western European (Windows) */
514 MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
515 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
516 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
517 1252, 1252, {'W','e','s','t','e','r','n',' ','E','u','r','o','p','e','a','n',' ','(','W','i','n','d','o','w','s',')',0},
518 {'W','i','n','d','o','w','s','-','1','2','5','2',0},
519 {'W','i','n','d','o','w','s','-','1','2','5','2',0},
520 {'i','s','o','-','8','8','5','9','-','1',0},
521 {'C','o','u','r','i','e','r',' ','N','e','w',0},
522 {'A','r','i','a','l',0}, 0
524 FALSE, FALSE, FALSE, FALSE, TRUE, TRUE
526 /* 20. Unicode */
529 MIMECONTF_MINIMAL | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
530 MIMECONTF_VALID | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
531 1200, 1200, {'U','n','i','c','o','d','e',0},
532 {'u','n','i','c','o','d','e',0},
533 {'u','n','i','c','o','d','e',0},
534 {'u','n','i','c','o','d','e',0},
535 {'C','o','u','r','i','e','r',' ','N','e','w',0},
536 {'A','r','i','a','l',0}, 1
541 static BOOL init_function_ptrs(void)
543 HMODULE hMlang;
545 hMlang = GetModuleHandleA("mlang.dll");
546 pConvertINetMultiByteToUnicode = (void *)GetProcAddress(hMlang, "ConvertINetMultiByteToUnicode");
547 pConvertINetUnicodeToMultiByte = (void *)GetProcAddress(hMlang, "ConvertINetUnicodeToMultiByte");
548 pRfc1766ToLcidA = (void *)GetProcAddress(hMlang, "Rfc1766ToLcidA");
549 pLcidToRfc1766A = (void *)GetProcAddress(hMlang, "LcidToRfc1766A");
551 pGetCPInfoExA = (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetCPInfoExA");
553 return TRUE;
556 #define ok_w2(format, szString1, szString2) \
558 if (lstrcmpW((szString1), (szString2)) != 0) \
560 CHAR string1[256], string2[256]; \
561 WideCharToMultiByte(CP_ACP, 0, (szString1), -1, string1, 256, NULL, NULL); \
562 WideCharToMultiByte(CP_ACP, 0, (szString2), -1, string2, 256, NULL, NULL); \
563 ok(0, (format), string1, string2); \
566 static void test_multibyte_to_unicode_translations(IMultiLanguage2 *iML2)
568 /* these APIs are broken regarding constness of the input buffer */
569 char stringA[] = "Just a test string\0"; /* double 0 for CP_UNICODE tests */
570 WCHAR stringW[] = {'J','u','s','t',' ','a',' ','t','e','s','t',' ','s','t','r','i','n','g',0};
571 char bufA[256];
572 WCHAR bufW[256];
573 UINT lenA, lenW, expected_len;
574 HRESULT ret;
576 /* IMultiLanguage2_ConvertStringToUnicode tests */
578 memset(bufW, 'x', sizeof(bufW));
579 lenA = 0;
580 lenW = ARRAY_SIZE(bufW);
581 ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, 1252, stringA, &lenA, bufW, &lenW);
582 ok(ret == S_OK, "IMultiLanguage2_ConvertStringToUnicode failed: %08lx\n", ret);
583 ok(lenA == 0, "expected lenA 0, got %u\n", lenA);
584 ok(lenW == 0, "expected lenW 0, got %u\n", lenW);
586 memset(bufW, 'x', sizeof(bufW));
587 lenA = -1;
588 lenW = ARRAY_SIZE(bufW);
589 ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, 1252, stringA, &lenA, bufW, &lenW);
590 ok(ret == S_OK, "IMultiLanguage2_ConvertStringToUnicode failed: %08lx\n", ret);
591 ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
592 ok(lenW == lstrlenW(stringW), "expected lenW %u, got %u\n", lstrlenW(stringW), lenW);
593 if (lenW < ARRAY_SIZE(bufW)) {
594 /* can only happen if the convert call fails */
595 ok(bufW[lenW] != 0, "buf should not be 0 terminated\n");
596 bufW[lenW] = 0; /* -1 doesn't include 0 terminator */
598 ok(!lstrcmpW(bufW, stringW), "bufW/stringW mismatch\n");
600 memset(bufW, 'x', sizeof(bufW));
601 lenA = -1;
602 lenW = 5;
603 ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, 1252, stringA, &lenA, bufW, &lenW);
604 ok(ret == E_FAIL, "IMultiLanguage2_ConvertStringToUnicode should fail: %08lx\n", ret);
605 ok(lenW == 0, "expected lenW 0, got %u\n", lenW);
606 /* still has to do partial conversion */
607 ok(!memcmp(bufW, stringW, 5 * sizeof(WCHAR)), "bufW/stringW mismatch\n");
609 memset(bufW, 'x', sizeof(bufW));
610 lenA = -1;
611 lenW = ARRAY_SIZE(bufW);
612 ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, CP_UNICODE, stringA, &lenA, bufW, &lenW);
613 ok(ret == S_OK, "IMultiLanguage2_ConvertStringToUnicode failed: %08lx\n", ret);
614 ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
615 ok(lenW == lstrlenW(stringW)/(int)sizeof(WCHAR), "wrong lenW %u\n", lenW);
616 ok(bufW[lenW] != 0, "buf should not be 0 terminated\n");
617 bufW[lenW] = 0; /* -1 doesn't include 0 terminator */
618 ok(!lstrcmpA((LPCSTR)bufW, stringA), "bufW/stringA mismatch\n");
620 memset(bufW, 'x', sizeof(bufW));
621 lenA = lstrlenA(stringA);
622 lenW = 0;
623 ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, 1252, stringA, &lenA, NULL, &lenW);
624 ok(ret == S_OK, "IMultiLanguage2_ConvertStringToUnicode failed: %08lx\n", ret);
625 ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
626 expected_len = MultiByteToWideChar(1252, 0, stringA, lenA, NULL, 0);
627 ok(lenW == expected_len, "expected lenW %u, got %u\n", expected_len, lenW);
629 memset(bufW, 'x', sizeof(bufW));
630 lenA = lstrlenA(stringA);
631 lenW = ARRAY_SIZE(bufW);
632 ret = pConvertINetMultiByteToUnicode(NULL, 1252, stringA, (INT *)&lenA, NULL, (INT *)&lenW);
633 ok(ret == S_OK, "ConvertINetMultiByteToUnicode failed: %08lx\n", ret);
634 ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
635 expected_len = MultiByteToWideChar(1252, 0, stringA, lenA, NULL, 0);
636 ok(lenW == expected_len, "expected lenW %u, got %u\n", expected_len, lenW);
638 memset(bufW, 'x', sizeof(bufW));
639 lenA = lstrlenA(stringA);
640 lenW = 0;
641 ret = pConvertINetMultiByteToUnicode(NULL, 1252, stringA, (INT *)&lenA, NULL, (INT *)&lenW);
642 ok(ret == S_OK, "ConvertINetMultiByteToUnicode failed: %08lx\n", ret);
643 ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
644 expected_len = MultiByteToWideChar(1252, 0, stringA, lenA, NULL, 0);
645 ok(lenW == expected_len, "expected lenW %u, got %u\n", expected_len, lenW);
647 /* IMultiLanguage2_ConvertStringFromUnicode tests */
649 memset(bufA, 'x', sizeof(bufA));
650 lenW = 0;
651 lenA = sizeof(bufA);
652 ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, stringW, &lenW, bufA, &lenA);
653 ok(ret == S_OK, "IMultiLanguage2_ConvertStringFromUnicode failed: %08lx\n", ret);
654 ok(lenA == 0, "expected lenA 0, got %u\n", lenA);
655 ok(lenW == 0, "expected lenW 0, got %u\n", lenW);
657 memset(bufA, 'x', sizeof(bufA));
658 lenW = -1;
659 lenA = sizeof(bufA);
660 ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, stringW, &lenW, bufA, &lenA);
661 ok(ret == S_OK, "IMultiLanguage2_ConvertStringFromUnicode failed: %08lx\n", ret);
662 ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
663 ok(lenW == lstrlenW(stringW), "expected lenW %u, got %u\n", lstrlenW(stringW), lenW);
664 ok(bufA[lenA] != 0, "buf should not be 0 terminated\n");
665 bufA[lenA] = 0; /* -1 doesn't include 0 terminator */
666 ok(!lstrcmpA(bufA, stringA), "bufA/stringA mismatch\n");
668 memset(bufA, 'x', sizeof(bufA));
669 lenW = -1;
670 lenA = 5;
671 ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, stringW, &lenW, bufA, &lenA);
672 ok(ret == E_FAIL, "IMultiLanguage2_ConvertStringFromUnicode should fail: %08lx\n", ret);
673 ok(lenA == 0, "expected lenA 0, got %u\n", lenA);
674 /* still has to do partial conversion */
675 ok(!memcmp(bufA, stringA, 5), "bufW/stringW mismatch\n");
677 memset(bufA, 'x', sizeof(bufA));
678 lenW = -1;
679 lenA = sizeof(bufA);
680 ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, CP_UNICODE, stringW, &lenW, bufA, &lenA);
681 ok(ret == S_OK, "IMultiLanguage2_ConvertStringFromUnicode failed: %08lx\n", ret);
682 ok(lenA == lstrlenA(stringA) * (int)sizeof(WCHAR), "wrong lenA %u\n", lenA);
683 ok(lenW == lstrlenW(stringW), "expected lenW %u, got %u\n", lstrlenW(stringW), lenW);
684 ok(bufA[lenA] != 0 && bufA[lenA+1] != 0, "buf should not be 0 terminated\n");
685 bufA[lenA] = 0; /* -1 doesn't include 0 terminator */
686 bufA[lenA+1] = 0; /* sizeof(WCHAR) */
687 ok(!lstrcmpW((LPCWSTR)bufA, stringW), "bufA/stringW mismatch\n");
689 memset(bufA, 'x', sizeof(bufA));
690 lenW = lstrlenW(stringW);
691 lenA = 0;
692 ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, stringW, &lenW, NULL, &lenA);
693 ok(ret == S_OK, "IMultiLanguage2_ConvertStringFromUnicode failed: %08lx\n", ret);
694 ok(lenW == lstrlenW(stringW), "expected lenW %u, got %u\n", lstrlenW(stringW), lenW);
695 expected_len = WideCharToMultiByte(1252, 0, stringW, lenW, NULL, 0, NULL, NULL);
696 ok(lenA == expected_len, "expected lenA %u, got %u\n", expected_len, lenA);
699 static void cpinfo_cmp(MIMECPINFO *cpinfo1, MIMECPINFO *cpinfo2)
701 ok(cpinfo1->dwFlags == cpinfo2->dwFlags, "dwFlags mismatch: %08lx != %08lx\n", cpinfo1->dwFlags, cpinfo2->dwFlags);
702 ok(cpinfo1->uiCodePage == cpinfo2->uiCodePage, "uiCodePage mismatch: %u != %u\n", cpinfo1->uiCodePage, cpinfo2->uiCodePage);
703 ok(cpinfo1->uiFamilyCodePage == cpinfo2->uiFamilyCodePage, "uiFamilyCodePage mismatch: %u != %u\n", cpinfo1->uiFamilyCodePage, cpinfo2->uiFamilyCodePage);
704 ok(!lstrcmpW(cpinfo1->wszDescription, cpinfo2->wszDescription), "wszDescription mismatch\n");
705 ok(!lstrcmpW(cpinfo1->wszWebCharset, cpinfo2->wszWebCharset), "wszWebCharset mismatch\n");
706 ok(!lstrcmpW(cpinfo1->wszHeaderCharset, cpinfo2->wszHeaderCharset), "wszHeaderCharset mismatch\n");
707 ok(!lstrcmpW(cpinfo1->wszBodyCharset, cpinfo2->wszBodyCharset), "wszBodyCharset mismatch\n");
708 ok(!lstrcmpW(cpinfo1->wszFixedWidthFont, cpinfo2->wszFixedWidthFont), "wszFixedWidthFont mismatch\n");
709 ok(!lstrcmpW(cpinfo1->wszProportionalFont, cpinfo2->wszProportionalFont), "wszProportionalFont mismatch\n");
710 ok(cpinfo1->bGDICharset == cpinfo2->bGDICharset, "bGDICharset mismatch: %d != %d\n", cpinfo1->bGDICharset, cpinfo2->bGDICharset);
713 #ifdef DUMP_CP_INFO
714 static const char *dump_mime_flags(DWORD flags)
716 static char buf[1024];
718 buf[0] = 0;
720 if (flags & MIMECONTF_MAILNEWS) strcat(buf, " MIMECONTF_MAILNEWS");
721 if (flags & MIMECONTF_BROWSER) strcat(buf, " MIMECONTF_BROWSER");
722 if (flags & MIMECONTF_MINIMAL) strcat(buf, " MIMECONTF_MINIMAL");
723 if (flags & MIMECONTF_IMPORT) strcat(buf, " MIMECONTF_IMPORT");
724 if (flags & MIMECONTF_SAVABLE_MAILNEWS) strcat(buf, " MIMECONTF_SAVABLE_MAILNEWS");
725 if (flags & MIMECONTF_SAVABLE_BROWSER) strcat(buf, " MIMECONTF_SAVABLE_BROWSER");
726 if (flags & MIMECONTF_EXPORT) strcat(buf, " MIMECONTF_EXPORT");
727 if (flags & MIMECONTF_PRIVCONVERTER) strcat(buf, " MIMECONTF_PRIVCONVERTER");
728 if (flags & MIMECONTF_VALID) strcat(buf, " MIMECONTF_VALID");
729 if (flags & MIMECONTF_VALID_NLS) strcat(buf, " MIMECONTF_VALID_NLS");
730 if (flags & MIMECONTF_MIME_IE4) strcat(buf, " MIMECONTF_MIME_IE4");
731 if (flags & MIMECONTF_MIME_LATEST) strcat(buf, " MIMECONTF_MIME_LATEST");
732 if (flags & MIMECONTF_MIME_REGISTRY) strcat(buf, " MIMECONTF_MIME_REGISTRY");
734 return buf;
736 #endif
738 static HRESULT check_convertible(IMultiLanguage2 *iML2, UINT from, UINT to)
740 CHAR convert[MAX_PATH];
741 BYTE dest[MAX_PATH];
742 HRESULT hr;
743 UINT srcsz, destsz;
745 static WCHAR strW[] = {'a','b','c',0};
747 /* Check to see if the target codepage has these characters or not */
748 if (from != CP_UTF8)
750 BOOL fDefaultChar;
751 char ch[10];
752 int cb;
753 cb = WideCharToMultiByte( from, WC_NO_BEST_FIT_CHARS | WC_COMPOSITECHECK | WC_DEFAULTCHAR,
754 strW, 3, ch, sizeof(ch), NULL, &fDefaultChar);
756 if(cb == 0 || fDefaultChar)
758 trace("target codepage %i does not contain 'abc'\n",from);
759 return E_FAIL;
763 srcsz = lstrlenW(strW) + 1;
764 destsz = MAX_PATH;
765 hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, from, strW,
766 &srcsz, convert, &destsz);
767 if (hr != S_OK)
768 return S_FALSE;
770 srcsz = -1;
771 destsz = MAX_PATH;
772 hr = IMultiLanguage2_ConvertString(iML2, NULL, from, to, (BYTE *)convert,
773 &srcsz, dest, &destsz);
774 if (hr != S_OK)
775 return S_FALSE;
777 return S_OK;
780 static void test_EnumCodePages(IMultiLanguage2 *iML2, DWORD flags)
782 IEnumCodePage *iEnumCP = NULL;
783 MIMECPINFO *cpinfo;
784 MIMECPINFO cpinfo2;
785 HRESULT ret;
786 ULONG i, n;
787 UINT total;
789 total = 0;
790 ret = IMultiLanguage2_GetNumberOfCodePageInfo(iML2, &total);
791 ok(ret == S_OK && total != 0, "IMultiLanguage2_GetNumberOfCodePageInfo: expected S_OK/!0, got %08lx/%u\n", ret, total);
793 trace("total mlang supported codepages %u\n", total);
795 ret = IMultiLanguage2_EnumCodePages(iML2, flags, LANG_NEUTRAL, &iEnumCP);
796 ok(ret == S_OK && iEnumCP, "IMultiLanguage2_EnumCodePages: expected S_OK/!NULL, got %08lx/%p\n", ret, iEnumCP);
798 ret = IEnumCodePage_Reset(iEnumCP);
799 ok(ret == S_OK, "IEnumCodePage_Reset: expected S_OK, got %08lx\n", ret);
800 n = 65536;
801 ret = IEnumCodePage_Next(iEnumCP, 0, NULL, &n);
802 ok(ret == S_FALSE || ret == E_FAIL,
803 "IEnumCodePage_Next: expected S_FALSE or E_FAIL, got %08lx\n", ret);
804 if (ret == S_FALSE)
805 ok(n == 0, "IEnumCodePage_Next: expected 0/S_FALSE, got %lu/%08lx\n", n, ret);
806 else if (ret == E_FAIL)
807 ok(n == 65536, "IEnumCodePage_Next: expected 65536/E_FAIL, got %lu/%08lx\n", n, ret);
808 ret = IEnumCodePage_Next(iEnumCP, 0, NULL, NULL);
809 ok(ret == S_FALSE || ret == E_FAIL,
810 "IEnumCodePage_Next: expected S_FALSE or E_FAIL, got %08lx\n", ret);
812 cpinfo = HeapAlloc(GetProcessHeap(), 0, sizeof(*cpinfo) * total * 2);
814 n = total * 2;
815 ret = IEnumCodePage_Next(iEnumCP, 0, cpinfo, &n);
816 ok(ret == S_FALSE && n == 0, "IEnumCodePage_Next: expected S_FALSE/0, got %08lx/%lu\n", ret, n);
818 n = total * 2;
819 ret = IEnumCodePage_Next(iEnumCP, n, cpinfo, &n);
820 ok(ret == S_OK && n != 0, "IEnumCodePage_Next: expected S_OK/!0, got %08lx/%lu\n", ret, n);
822 trace("flags %08lx, enumerated codepages %lu\n", flags, n);
824 if (!flags)
826 ok(n == total, "IEnumCodePage_Next: expected %u, got %lu\n", total, n);
828 flags = MIMECONTF_MIME_LATEST;
831 total = n;
833 for (i = 0; i < n; i++)
835 CHARSETINFO csi;
836 MIMECSETINFO mcsi;
837 HRESULT convertible = S_OK;
838 static const WCHAR autoW[] = {'_','a','u','t','o',0};
839 static const WCHAR feffW[] = {'u','n','i','c','o','d','e','F','E','F','F',0};
841 #ifdef DUMP_CP_INFO
842 trace("MIMECPINFO #%u:\n"
843 "dwFlags %08x %s\n"
844 "uiCodePage %u\n"
845 "uiFamilyCodePage %u\n"
846 "wszDescription %s\n"
847 "wszWebCharset %s\n"
848 "wszHeaderCharset %s\n"
849 "wszBodyCharset %s\n"
850 "wszFixedWidthFont %s\n"
851 "wszProportionalFont %s\n"
852 "bGDICharset %d\n\n",
854 cpinfo[i].dwFlags, dump_mime_flags(cpinfo[i].dwFlags),
855 cpinfo[i].uiCodePage,
856 cpinfo[i].uiFamilyCodePage,
857 wine_dbgstr_w(cpinfo[i].wszDescription),
858 wine_dbgstr_w(cpinfo[i].wszWebCharset),
859 wine_dbgstr_w(cpinfo[i].wszHeaderCharset),
860 wine_dbgstr_w(cpinfo[i].wszBodyCharset),
861 wine_dbgstr_w(cpinfo[i].wszFixedWidthFont),
862 wine_dbgstr_w(cpinfo[i].wszProportionalFont),
863 cpinfo[i].bGDICharset);
864 #endif
865 ok(cpinfo[i].dwFlags & flags, "enumerated flags %08lx do not include requested %08lx\n", cpinfo[i].dwFlags, flags);
867 if (TranslateCharsetInfo((DWORD *)(INT_PTR)cpinfo[i].uiFamilyCodePage, &csi, TCI_SRCCODEPAGE))
868 ok(cpinfo[i].bGDICharset == csi.ciCharset, "%d != %d\n", cpinfo[i].bGDICharset, csi.ciCharset);
869 else
870 if (winetest_debug > 1)
871 trace("TranslateCharsetInfo failed for cp %u\n", cpinfo[i].uiFamilyCodePage);
873 #ifdef DUMP_CP_INFO
874 trace("%u: codepage %u family %u\n", i, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
875 #endif
877 /* support files for some codepages might be not installed, or
878 * the codepage is just an alias.
880 if (IsValidCodePage(cpinfo[i].uiCodePage))
882 ret = IMultiLanguage2_IsConvertible(iML2, cpinfo[i].uiCodePage, CP_UNICODE);
883 ok(ret == S_OK, "IMultiLanguage2_IsConvertible(%u -> CP_UNICODE) = %08lx\n", cpinfo[i].uiCodePage, ret);
884 ret = IMultiLanguage2_IsConvertible(iML2, CP_UNICODE, cpinfo[i].uiCodePage);
885 ok(ret == S_OK, "IMultiLanguage2_IsConvertible(CP_UNICODE -> %u) = %08lx\n", cpinfo[i].uiCodePage, ret);
887 convertible = check_convertible(iML2, cpinfo[i].uiCodePage, CP_UTF8);
888 if (convertible != E_FAIL)
890 ret = IMultiLanguage2_IsConvertible(iML2, cpinfo[i].uiCodePage, CP_UTF8);
891 ok(ret == convertible, "IMultiLanguage2_IsConvertible(%u -> CP_UTF8) = %08lx\n", cpinfo[i].uiCodePage, ret);
892 ret = IMultiLanguage2_IsConvertible(iML2, CP_UTF8, cpinfo[i].uiCodePage);
893 ok(ret == convertible, "IMultiLanguage2_IsConvertible(CP_UTF8 -> %u) = %08lx\n", cpinfo[i].uiCodePage, ret);
896 else
897 if (winetest_debug > 1)
898 trace("IsValidCodePage failed for cp %u\n", cpinfo[i].uiCodePage);
900 if (memcmp(cpinfo[i].wszWebCharset,feffW,sizeof(WCHAR)*11)==0)
901 skip("Legacy windows bug returning invalid charset of unicodeFEFF\n");
902 else
904 ret = IMultiLanguage2_GetCharsetInfo(iML2, cpinfo[i].wszWebCharset, &mcsi);
905 /* _autoxxx charsets are a fake and GetCharsetInfo fails for them */
906 if (memcmp(cpinfo[i].wszWebCharset, autoW, 5 * sizeof(WCHAR)))
908 ok (ret == S_OK, "IMultiLanguage2_GetCharsetInfo failed: %08lx\n", ret);
909 #ifdef DUMP_CP_INFO
910 trace("%s: %u %u %s\n", wine_dbgstr_w(cpinfo[i].wszWebCharset), mcsi.uiCodePage, mcsi.uiInternetEncoding, wine_dbgstr_w(mcsi.wszCharset));
911 #endif
912 ok(!lstrcmpiW(cpinfo[i].wszWebCharset, mcsi.wszCharset), "%s != %s\n",
913 wine_dbgstr_w(cpinfo[i].wszWebCharset), wine_dbgstr_w(mcsi.wszCharset));
915 if (0)
917 /* native mlang returns completely messed up encodings in some cases */
918 ok(mcsi.uiInternetEncoding == cpinfo[i].uiCodePage || mcsi.uiInternetEncoding == cpinfo[i].uiFamilyCodePage,
919 "%u != %u || %u\n", mcsi.uiInternetEncoding, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
920 ok(mcsi.uiCodePage == cpinfo[i].uiCodePage || mcsi.uiCodePage == cpinfo[i].uiFamilyCodePage,
921 "%u != %u || %u\n", mcsi.uiCodePage, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
926 if (memcmp(cpinfo[i].wszHeaderCharset,feffW,sizeof(WCHAR)*11)==0)
927 skip("Legacy windows bug returning invalid charset of unicodeFEFF\n");
928 else
930 ret = IMultiLanguage2_GetCharsetInfo(iML2, cpinfo[i].wszHeaderCharset, &mcsi);
931 /* _autoxxx charsets are a fake and GetCharsetInfo fails for them */
932 if (memcmp(cpinfo[i].wszHeaderCharset, autoW, 5 * sizeof(WCHAR)))
934 ok (ret == S_OK, "IMultiLanguage2_GetCharsetInfo failed: %08lx\n", ret);
935 #ifdef DUMP_CP_INFO
936 trace("%s: %u %u %s\n", wine_dbgstr_w(cpinfo[i].wszHeaderCharset), mcsi.uiCodePage, mcsi.uiInternetEncoding, wine_dbgstr_w(mcsi.wszCharset));
937 #endif
938 ok(!lstrcmpiW(cpinfo[i].wszHeaderCharset, mcsi.wszCharset), "%s != %s\n",
939 wine_dbgstr_w(cpinfo[i].wszHeaderCharset), wine_dbgstr_w(mcsi.wszCharset));
941 if (0)
943 /* native mlang returns completely messed up encodings in some cases */
944 ok(mcsi.uiInternetEncoding == cpinfo[i].uiCodePage || mcsi.uiInternetEncoding == cpinfo[i].uiFamilyCodePage,
945 "%u != %u || %u\n", mcsi.uiInternetEncoding, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
946 ok(mcsi.uiCodePage == cpinfo[i].uiCodePage || mcsi.uiCodePage == cpinfo[i].uiFamilyCodePage,
947 "%u != %u || %u\n", mcsi.uiCodePage, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
952 if (memcmp(cpinfo[i].wszBodyCharset,feffW,sizeof(WCHAR)*11)==0)
953 skip("Legacy windows bug returning invalid charset of unicodeFEFF\n");
954 else
956 ret = IMultiLanguage2_GetCharsetInfo(iML2, cpinfo[i].wszBodyCharset, &mcsi);
957 /* _autoxxx charsets are a fake and GetCharsetInfo fails for them */
958 if (memcmp(cpinfo[i].wszBodyCharset, autoW, 5 * sizeof(WCHAR)))
960 ok (ret == S_OK, "IMultiLanguage2_GetCharsetInfo failed: %08lx\n", ret);
961 #ifdef DUMP_CP_INFO
962 trace("%s: %u %u %s\n", wine_dbgstr_w(cpinfo[i].wszBodyCharset), mcsi.uiCodePage, mcsi.uiInternetEncoding, wine_dbgstr_w(mcsi.wszCharset));
963 #endif
964 ok(!lstrcmpiW(cpinfo[i].wszBodyCharset, mcsi.wszCharset), "%s != %s\n",
965 wine_dbgstr_w(cpinfo[i].wszBodyCharset), wine_dbgstr_w(mcsi.wszCharset));
967 if (0)
969 /* native mlang returns completely messed up encodings in some cases */
970 ok(mcsi.uiInternetEncoding == cpinfo[i].uiCodePage || mcsi.uiInternetEncoding == cpinfo[i].uiFamilyCodePage,
971 "%u != %u || %u\n", mcsi.uiInternetEncoding, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
972 ok(mcsi.uiCodePage == cpinfo[i].uiCodePage || mcsi.uiCodePage == cpinfo[i].uiFamilyCodePage,
973 "%u != %u || %u\n", mcsi.uiCodePage, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
979 /* now IEnumCodePage_Next should fail, since pointer is at the end */
980 n = 1;
981 ret = IEnumCodePage_Next(iEnumCP, 1, &cpinfo2, &n);
982 ok(ret == S_FALSE && n == 0, "IEnumCodePage_Next: expected S_FALSE/0, got %08lx/%lu\n", ret, n);
984 ret = IEnumCodePage_Reset(iEnumCP);
985 ok(ret == S_OK, "IEnumCodePage_Reset: expected S_OK, got %08lx\n", ret);
986 n = 0;
987 ret = IEnumCodePage_Next(iEnumCP, 1, &cpinfo2, &n);
988 ok(n == 1 && ret == S_OK, "IEnumCodePage_Next: expected 1/S_OK, got %lu/%08lx\n", n, ret);
989 cpinfo_cmp(cpinfo, &cpinfo2);
991 if (0)
993 /* Due to a bug in MS' implementation of IEnumCodePage_Skip
994 * it's not used here.
996 ret = IEnumCodePage_Skip(iEnumCP, 1);
997 ok(ret == S_OK, "IEnumCodePage_Skip: expected S_OK, got %08lx\n", ret);
999 for (i = 0; i < total - 1; i++)
1001 n = 0;
1002 ret = IEnumCodePage_Next(iEnumCP, 1, &cpinfo2, &n);
1003 ok(n == 1 && ret == S_OK, "IEnumCodePage_Next: expected 1/S_OK, got %lu/%08lx\n", n, ret);
1004 cpinfo_cmp(&cpinfo[i + 1], &cpinfo2);
1007 HeapFree(GetProcessHeap(), 0, cpinfo);
1008 IEnumCodePage_Release(iEnumCP);
1011 static void test_GetCharsetInfo_other(IMultiLanguage *ml)
1013 WCHAR asciiW[] = {'a','s','c','i','i',0};
1014 WCHAR iso88591_1W[] = {'I','S','O','-','8','8','5','9','-','1',0};
1015 WCHAR iso88591_1retW[] = {'i','s','o','-','8','8','5','9','-','1',0};
1016 WCHAR iso88591_2W[] = {'I','S','O','8','8','5','9','-','1',0};
1017 WCHAR iso88591_2retW[] = {'i','s','o','8','8','5','9','-','1',0};
1018 WCHAR iso88591_3W[] = {'I','S','O','8','8','5','9','1',0};
1019 WCHAR iso88591_4W[] = {'I','S','O','-','8','8','5','9','1',0};
1020 WCHAR iso88591_5W[] = {'I','S','O','8','8','-','5','9','1',0};
1021 WCHAR iso88591_6W[] = {'-','I','S','O','8','8','5','9','1',0};
1022 WCHAR iso88591_7W[] = {' ','I','S','O','-','8','8','5','9','-','1',0};
1023 struct other {
1024 int todo;
1025 HRESULT hr;
1026 WCHAR* charset;
1027 WCHAR* ret_charset;
1028 } other[] = {
1029 { 0, S_OK, asciiW, asciiW },
1030 { 0, S_OK, iso88591_1W, iso88591_1retW },
1031 { 1, S_OK, iso88591_2W, iso88591_2retW },
1032 { 0, E_FAIL, iso88591_3W, 0 },
1033 { 0, E_FAIL, iso88591_4W, 0 },
1034 { 0, E_FAIL, iso88591_5W, 0 },
1035 { 0, E_FAIL, iso88591_6W, 0 },
1036 { 0, E_FAIL, iso88591_7W, 0 },
1038 MIMECSETINFO info;
1039 HRESULT hr;
1040 int i;
1042 for (i = 0; i < ARRAY_SIZE(other); i++)
1044 hr = IMultiLanguage_GetCharsetInfo(ml, other[i].charset, &info);
1046 todo_wine_if(other[i].todo)
1047 ok(hr == other[i].hr, "#%d: got %08lx, expected %08lx\n", i, hr, other[i].hr);
1049 if (hr == S_OK)
1050 todo_wine_if(other[i].todo)
1051 ok(!lstrcmpW(info.wszCharset, other[i].ret_charset), "#%d: got %s, expected %s\n",
1052 i, wine_dbgstr_w(info.wszCharset), wine_dbgstr_w(other[i].ret_charset));
1056 static void scriptinfo_cmp(SCRIPTINFO *sinfo1, SCRIPTINFO *sinfo2)
1058 ok(sinfo1->ScriptId == sinfo2->ScriptId, "ScriptId mismatch: %d != %d\n", sinfo1->ScriptId, sinfo2->ScriptId);
1059 ok(sinfo1->uiCodePage == sinfo2->uiCodePage, "uiCodePage mismatch: %u != %u\n", sinfo1->uiCodePage, sinfo2->uiCodePage);
1060 ok(!lstrcmpW(sinfo1->wszDescription, sinfo2->wszDescription), "wszDescription mismatch\n");
1061 ok(!lstrcmpW(sinfo1->wszFixedWidthFont, sinfo2->wszFixedWidthFont), "wszFixedWidthFont mismatch\n");
1062 ok(!lstrcmpW(sinfo1->wszProportionalFont, sinfo2->wszProportionalFont), "wszProportionalFont mismatch\n");
1065 static void test_EnumScripts(IMultiLanguage2 *iML2, DWORD flags)
1067 IEnumScript *iEnumScript = NULL;
1068 SCRIPTINFO *sinfo;
1069 SCRIPTINFO sinfo2;
1070 HRESULT ret;
1071 ULONG i, n;
1072 UINT total;
1074 total = 0;
1075 ret = IMultiLanguage2_GetNumberOfScripts(iML2, &total);
1076 ok(ret == S_OK && total != 0, "IMultiLanguage2_GetNumberOfScripts: expected S_OK/!0, got %08lx/%u\n", ret, total);
1078 trace("total mlang supported scripts %u\n", total);
1080 ret = IMultiLanguage2_EnumScripts(iML2, flags, LANG_NEUTRAL, &iEnumScript);
1081 ok(ret == S_OK && iEnumScript, "IMultiLanguage2_EnumScripts: expected S_OK/!NULL, got %08lx/%p\n", ret, iEnumScript);
1083 ret = IEnumScript_Reset(iEnumScript);
1084 ok(ret == S_OK, "IEnumScript_Reset: expected S_OK, got %08lx\n", ret);
1085 n = 65536;
1086 ret = IEnumScript_Next(iEnumScript, 0, NULL, &n);
1087 ok(n == 65536 && ret == E_FAIL, "IEnumScript_Next: expected 65536/E_FAIL, got %lu/%08lx\n", n, ret);
1088 ret = IEnumScript_Next(iEnumScript, 0, NULL, NULL);
1089 ok(ret == E_FAIL, "IEnumScript_Next: expected E_FAIL, got %08lx\n", ret);
1091 sinfo = HeapAlloc(GetProcessHeap(), 0, sizeof(*sinfo) * total * 2);
1093 n = total * 2;
1094 ret = IEnumScript_Next(iEnumScript, 0, sinfo, &n);
1095 ok(ret == S_FALSE && n == 0, "IEnumScript_Next: expected S_FALSE/0, got %08lx/%lu\n", ret, n);
1097 n = total * 2;
1098 ret = IEnumScript_Next(iEnumScript, n, sinfo, &n);
1099 ok(ret == S_OK && n != 0, "IEnumScript_Next: expected S_OK, got %08lx/%lu\n", ret, n);
1101 trace("flags %08lx, enumerated scripts %lu\n", flags, n);
1103 if (!flags)
1105 ok(n == total, "IEnumScript_Next: expected %u, got %lu\n", total, n);
1108 total = n;
1110 for (i = 0; pGetCPInfoExA && i < n; i++)
1112 #ifdef DUMP_SCRIPT_INFO
1113 trace("SCRIPTINFO #%u:\n"
1114 "ScriptId %08x\n"
1115 "uiCodePage %u\n"
1116 "wszDescription %s\n"
1117 "wszFixedWidthFont %s\n"
1118 "wszProportionalFont %s\n\n",
1120 sinfo[i].ScriptId,
1121 sinfo[i].uiCodePage,
1122 wine_dbgstr_w(sinfo[i].wszDescription),
1123 wine_dbgstr_w(sinfo[i].wszFixedWidthFont),
1124 wine_dbgstr_w(sinfo[i].wszProportionalFont));
1125 trace("%u codepage %u\n", i, sinfo[i].uiCodePage);
1126 #endif
1129 /* now IEnumScript_Next should fail, since pointer is at the end */
1130 n = 1;
1131 ret = IEnumScript_Next(iEnumScript, 1, &sinfo2, &n);
1132 ok(ret == S_FALSE && n == 0, "IEnumScript_Next: expected S_FALSE/0, got %08lx/%lu\n", ret, n);
1134 ret = IEnumScript_Reset(iEnumScript);
1135 ok(ret == S_OK, "IEnumScript_Reset: expected S_OK, got %08lx\n", ret);
1136 n = 0;
1137 ret = IEnumScript_Next(iEnumScript, 1, &sinfo2, &n);
1138 ok(n == 1 && ret == S_OK, "IEnumScript_Next: expected 1/S_OK, got %lu/%08lx\n", n, ret);
1139 scriptinfo_cmp(sinfo, &sinfo2);
1141 if (0)
1143 /* Due to a bug in MS' implementation of IEnumScript_Skip
1144 * it's not used here.
1146 ret = IEnumScript_Skip(iEnumScript, 1);
1147 ok(ret == S_OK, "IEnumScript_Skip: expected S_OK, got %08lx\n", ret);
1149 for (i = 0; i < total - 1; i++)
1151 n = 0;
1152 ret = IEnumScript_Next(iEnumScript, 1, &sinfo2, &n);
1153 ok(n == 1 && ret == S_OK, "IEnumScript_Next: expected 1/S_OK, got %lu/%08lx\n", n, ret);
1154 scriptinfo_cmp(&sinfo[i + 1], &sinfo2);
1157 HeapFree(GetProcessHeap(), 0, sinfo);
1158 IEnumScript_Release(iEnumScript);
1161 static void IMLangFontLink_Test(IMLangFontLink* iMLFL)
1163 DWORD dwCodePages, dwManyCodePages;
1164 DWORD dwCmpCodePages;
1165 UINT CodePage;
1166 static const WCHAR str[] = { 'd', 0x0436, 0xff90, 0x0160 };
1167 LONG processed;
1168 HRESULT ret;
1170 dwCodePages = ~0u;
1171 ret = IMLangFontLink_CodePageToCodePages(iMLFL, -1, &dwCodePages);
1172 ok(ret == E_FAIL, "IMLangFontLink_CodePageToCodePages should fail: %lx\n", ret);
1173 ok(dwCodePages == 0, "expected 0, got %lu\n", dwCodePages);
1175 dwCodePages = 0;
1176 ret = IMLangFontLink_CodePageToCodePages(iMLFL, 932, &dwCodePages);
1177 ok(ret == S_OK, "IMLangFontLink_CodePageToCodePages error %lx\n", ret);
1178 ok(dwCodePages == FS_JISJAPAN, "expected FS_JISJAPAN, got %08lx\n", dwCodePages);
1179 CodePage = 0;
1180 ret = IMLangFontLink_CodePagesToCodePage(iMLFL, dwCodePages, 1035, &CodePage);
1181 ok(ret == S_OK, "IMLangFontLink_CodePagesToCodePage error %lx\n", ret);
1182 ok(CodePage == 932, "Incorrect CodePage Returned (%i)\n",CodePage);
1184 dwManyCodePages = 0;
1185 ret = IMLangFontLink_CodePageToCodePages(iMLFL, 1252, &dwManyCodePages);
1186 ok(ret == S_OK, "IMLangFontLink_CodePageToCodePages error %lx\n", ret);
1187 ok(dwManyCodePages == FS_LATIN1, "expected FS_LATIN1, got %08lx\n", dwManyCodePages);
1188 dwCodePages = 0;
1189 ret = IMLangFontLink_CodePageToCodePages(iMLFL, 1256, &dwCodePages);
1190 ok(ret == S_OK, "IMLangFontLink_CodePageToCodePages error %lx\n", ret);
1191 ok(dwCodePages == FS_ARABIC, "expected FS_ARABIC, got %08lx\n", dwCodePages);
1192 dwManyCodePages |= dwCodePages;
1193 ret = IMLangFontLink_CodePageToCodePages(iMLFL, 874, &dwCodePages);
1194 ok(ret == S_OK, "IMLangFontLink_CodePageToCodePages error %lx\n", ret);
1195 ok(dwCodePages == FS_THAI, "expected FS_THAI, got %08lx\n", dwCodePages);
1196 dwManyCodePages |= dwCodePages;
1198 ret = IMLangFontLink_CodePagesToCodePage(iMLFL, dwManyCodePages, 1256, &CodePage);
1199 ok(ret == S_OK, "IMLangFontLink_CodePagesToCodePage error %lx\n", ret);
1200 ok(CodePage == 1256, "Incorrect CodePage Returned (%i)\n",CodePage);
1202 ret = IMLangFontLink_CodePagesToCodePage(iMLFL, dwManyCodePages, 936, &CodePage);
1203 ok(ret == S_OK, "IMLangFontLink_CodePagesToCodePage error %lx\n", ret);
1204 ok(CodePage == 1252, "Incorrect CodePage Returned (%i)\n",CodePage);
1206 /* Tests for GetCharCodePages */
1208 /* Latin 1 */
1209 dwCmpCodePages = FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC | FS_GREEK | FS_TURKISH
1210 | FS_HEBREW | FS_ARABIC | FS_BALTIC | FS_VIETNAMESE | FS_THAI
1211 | FS_JISJAPAN | FS_CHINESESIMP | FS_WANSUNG | FS_CHINESETRAD;
1212 ret = IMLangFontLink_GetCharCodePages(iMLFL, 'd', &dwCodePages);
1213 ok(ret == S_OK, "IMLangFontLink_GetCharCodePages error %lx\n", ret);
1214 ok(dwCodePages == dwCmpCodePages, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
1216 dwCodePages = 0;
1217 processed = 0;
1218 ret = IMLangFontLink_GetStrCodePages(iMLFL, str, 1, 0, &dwCodePages, &processed);
1219 ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %lx\n", ret);
1220 ok(dwCodePages == dwCmpCodePages, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
1221 ok(processed == 1, "expected 1, got %ld\n", processed);
1223 /* Latin 2 */
1224 dwCmpCodePages = FS_LATIN1 | FS_LATIN2 | FS_TURKISH | FS_BALTIC;
1225 ret = IMLangFontLink_GetCharCodePages(iMLFL, 0x0160, &dwCodePages);
1226 ok(ret == S_OK, "IMLangFontLink_GetCharCodePages error %lx\n", ret);
1227 ok(dwCodePages == dwCmpCodePages, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
1229 dwCodePages = 0;
1230 processed = 0;
1231 ret = IMLangFontLink_GetStrCodePages(iMLFL, &str[3], 1, 0, &dwCodePages, &processed);
1232 ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %lx\n", ret);
1233 ok(dwCodePages == dwCmpCodePages, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
1234 ok(processed == 1, "expected 1, got %ld\n", processed);
1236 /* Cyrillic */
1237 dwCmpCodePages = FS_CYRILLIC | FS_JISJAPAN | FS_CHINESESIMP | FS_WANSUNG;
1238 ret = IMLangFontLink_GetCharCodePages(iMLFL, 0x0436, &dwCodePages);
1239 ok(ret == S_OK, "IMLangFontLink_GetCharCodePages error %lx\n", ret);
1240 ok(dwCodePages == dwCmpCodePages, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
1242 dwCodePages = 0;
1243 processed = 0;
1244 ret = IMLangFontLink_GetStrCodePages(iMLFL, &str[1], 1, 0, &dwCodePages, &processed);
1245 ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %lx\n", ret);
1246 ok(dwCodePages == dwCmpCodePages, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
1247 ok(processed == 1, "expected 1, got %ld\n", processed);
1249 /* Japanese */
1250 dwCmpCodePages = FS_JISJAPAN;
1251 ret = IMLangFontLink_GetCharCodePages(iMLFL, 0xff90, &dwCodePages);
1252 ok(ret == S_OK, "IMLangFontLink_GetCharCodePages error %lx\n", ret);
1253 ok(dwCodePages == dwCmpCodePages, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
1255 dwCodePages = 0;
1256 processed = 0;
1257 ret = IMLangFontLink_GetStrCodePages(iMLFL, &str[2], 1, 0, &dwCodePages, &processed);
1258 ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %lx\n", ret);
1259 ok(dwCodePages == dwCmpCodePages, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
1260 ok(processed == 1, "expected 1, got %ld\n", processed);
1262 dwCmpCodePages = FS_CYRILLIC | FS_JISJAPAN | FS_CHINESESIMP | FS_WANSUNG;
1263 dwCodePages = 0;
1264 processed = 0;
1265 ret = IMLangFontLink_GetStrCodePages(iMLFL, str, 2, 0, &dwCodePages, &processed);
1266 ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %lx\n", ret);
1267 ok(dwCodePages == dwCmpCodePages, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
1268 ok(processed == 2, "expected 2, got %ld\n", processed);
1270 dwCmpCodePages = FS_JISJAPAN;
1271 dwCodePages = 0;
1272 processed = 0;
1273 ret = IMLangFontLink_GetStrCodePages(iMLFL, str, 3, 0, &dwCodePages, &processed);
1274 ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %lx\n", ret);
1275 ok(dwCodePages == dwCmpCodePages, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
1276 ok(processed == 3, "expected 3, got %ld\n", processed);
1278 dwCmpCodePages = FS_JISJAPAN;
1279 dwCodePages = 0;
1280 processed = 0;
1281 ret = IMLangFontLink_GetStrCodePages(iMLFL, str, 4, 0, &dwCodePages, &processed);
1282 ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %lx\n", ret);
1283 ok(dwCodePages == dwCmpCodePages, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
1284 ok(processed == 3, "expected 3, got %ld\n", processed);
1286 dwCodePages = 0xffff;
1287 processed = -1;
1288 ret = IMLangFontLink_GetStrCodePages(iMLFL, &str[2], 1, 0, &dwCodePages, &processed);
1289 ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %lx\n", ret);
1290 ok(dwCodePages == dwCmpCodePages, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
1291 ok(processed == 1, "expected 0, got %ld\n", processed);
1293 ret = IMLangFontLink_GetStrCodePages(iMLFL, &str[2], 1, 0, NULL, NULL);
1294 ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %lx\n", ret);
1296 dwCodePages = 0xffff;
1297 processed = -1;
1298 ret = IMLangFontLink_GetStrCodePages(iMLFL, str, -1, 0, &dwCodePages, &processed);
1299 ok(ret == E_INVALIDARG, "IMLangFontLink_GetStrCodePages should fail: %lx\n", ret);
1300 ok(dwCodePages == 0, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
1301 ok(processed == 0, "expected 0, got %ld\n", processed);
1303 dwCodePages = 0xffff;
1304 processed = -1;
1305 ret = IMLangFontLink_GetStrCodePages(iMLFL, NULL, 1, 0, &dwCodePages, &processed);
1306 ok(ret == E_INVALIDARG, "IMLangFontLink_GetStrCodePages should fail: %lx\n", ret);
1307 ok(dwCodePages == 0, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
1308 ok(processed == 0, "expected 0, got %ld\n", processed);
1310 dwCodePages = 0xffff;
1311 processed = -1;
1312 ret = IMLangFontLink_GetStrCodePages(iMLFL, str, 0, 0, &dwCodePages, &processed);
1313 ok(ret == E_INVALIDARG, "IMLangFontLink_GetStrCodePages should fail: %lx\n", ret);
1314 ok(dwCodePages == 0, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
1315 ok(processed == 0, "expected 0, got %ld\n", processed);
1318 static void test_rfc1766(IMultiLanguage2 *iML2)
1320 IEnumRfc1766 *pEnumRfc1766;
1321 RFC1766INFO info;
1322 ULONG n;
1323 HRESULT ret;
1324 BSTR rfcstr;
1326 ret = IMultiLanguage2_EnumRfc1766(iML2, LANG_NEUTRAL, &pEnumRfc1766);
1327 ok(ret == S_OK, "IMultiLanguage2_EnumRfc1766 error %08lx\n", ret);
1329 while (1)
1331 ret = IEnumRfc1766_Next(pEnumRfc1766, 1, &info, &n);
1332 if (ret != S_OK) break;
1334 #ifdef DUMP_CP_INFO
1335 trace("lcid %04x rfc_name %s locale_name %s\n",
1336 info.lcid, wine_dbgstr_w(info.wszRfc1766), wine_dbgstr_w(info.wszLocaleName));
1337 #endif
1339 ok(n == 1, "couldn't fetch 1 RFC1766INFO structure\n");
1341 /* verify the Rfc1766 value */
1342 ret = IMultiLanguage2_GetRfc1766FromLcid(iML2, info.lcid, &rfcstr);
1343 ok(ret == S_OK, "Expected S_OK, got %08lx\n", ret);
1345 /* not an exact 1:1 correspondence between lcid and rfc1766 in the
1346 * mlang database, e.g., nb-no -> 1044 -> no */
1347 ok(wcsstr(info.wszRfc1766, rfcstr) != NULL,
1348 "Expected matching locale names\n");
1350 SysFreeString(rfcstr);
1352 IEnumRfc1766_Release(pEnumRfc1766);
1355 static void test_GetLcidFromRfc1766(IMultiLanguage2 *iML2)
1357 WCHAR rfc1766W[MAX_RFC1766_NAME + 1];
1358 LCID lcid;
1359 HRESULT ret;
1360 DWORD i;
1362 static WCHAR en[] = { 'e','n',0 };
1363 static WCHAR en_them[] = { 'e','n','-','t','h','e','m',0 };
1364 static WCHAR english[] = { 'e','n','g','l','i','s','h',0 };
1367 for(i = 0; i < ARRAY_SIZE(lcid_table); i++) {
1368 lcid = -1;
1369 MultiByteToWideChar(CP_ACP, 0, lcid_table[i].rfc1766, -1, rfc1766W, MAX_RFC1766_NAME);
1370 ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, rfc1766W);
1372 /* IE <6.0 guess 0x412 (ko) from "kok" */
1373 ok((ret == lcid_table[i].hr) ||
1374 broken(lcid_table[i].broken_lcid && (ret == S_FALSE)),
1375 "#%02ld: HRESULT 0x%lx (expected 0x%lx)\n", i, ret, lcid_table[i].hr);
1377 ok((lcid == lcid_table[i].lcid) ||
1378 broken(lcid == lcid_table[i].broken_lcid), /* IE <6.0 */
1379 "#%02ld: got LCID 0x%lx (expected 0x%lx)\n", i, lcid, lcid_table[i].lcid);
1383 ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, NULL, en);
1384 ok(ret == E_INVALIDARG, "GetLcidFromRfc1766 returned: %08lx\n", ret);
1386 ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, NULL);
1387 ok(ret == E_INVALIDARG, "GetLcidFromRfc1766 returned: %08lx\n", ret);
1389 ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, en_them);
1390 ok((ret == E_FAIL || ret == S_FALSE), "GetLcidFromRfc1766 returned: %08lx\n", ret);
1391 if (ret == S_FALSE)
1393 BSTR rfcstr;
1394 static WCHAR en[] = {'e','n',0};
1396 ret = IMultiLanguage2_GetRfc1766FromLcid(iML2, lcid, &rfcstr);
1397 ok(ret == S_OK, "Expected S_OK, got %08lx\n", ret);
1398 ok_w2("Expected \"%s\", got \"%s\"n", en, rfcstr);
1401 ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, english);
1402 ok((ret == E_FAIL || ret == S_FALSE), "GetLcidFromRfc1766 returned: %08lx\n", ret);
1403 if (ret == S_FALSE)
1405 BSTR rfcstr;
1406 static WCHAR en[] = {'e','n',0};
1408 ret = IMultiLanguage2_GetRfc1766FromLcid(iML2, lcid, &rfcstr);
1409 ok(ret == S_OK, "Expected S_OK, got %08lx\n", ret);
1410 ok_w2("Expected \"%s\", got \"%s\"n", en, rfcstr);
1415 static void test_Rfc1766ToLcid(void)
1417 LCID lcid;
1418 HRESULT ret;
1419 DWORD i;
1421 for(i = 0; i < ARRAY_SIZE(lcid_table); i++) {
1422 lcid = -1;
1423 ret = pRfc1766ToLcidA(&lcid, lcid_table[i].rfc1766);
1425 /* IE <6.0 guess 0x412 (ko) from "kok" */
1426 ok( (ret == lcid_table[i].hr) ||
1427 broken(lcid_table[i].broken_lcid && (ret == S_FALSE)),
1428 "#%02ld: HRESULT 0x%lx (expected 0x%lx)\n", i, ret, lcid_table[i].hr);
1430 ok( (lcid == lcid_table[i].lcid) ||
1431 broken(lcid == lcid_table[i].broken_lcid), /* IE <6.0 */
1432 "#%02ld: got LCID 0x%lx (expected 0x%lx)\n", i, lcid, lcid_table[i].lcid);
1435 ret = pRfc1766ToLcidA(&lcid, NULL);
1436 ok(ret == E_INVALIDARG, "got 0x%08lx (expected E_INVALIDARG)\n", ret);
1438 ret = pRfc1766ToLcidA(NULL, "en");
1439 ok(ret == E_INVALIDARG, "got 0x%08lx (expected E_INVALIDARG)\n", ret);
1442 static void test_GetNumberOfCodePageInfo(IMultiLanguage2 *iML2)
1444 HRESULT hr;
1445 UINT value;
1447 value = 0xdeadbeef;
1448 hr = IMultiLanguage2_GetNumberOfCodePageInfo(iML2, &value);
1449 ok( (hr == S_OK) && value,
1450 "got 0x%lx with %d (expected S_OK with '!= 0')\n", hr, value);
1452 hr = IMultiLanguage2_GetNumberOfCodePageInfo(iML2, NULL);
1453 ok(hr == E_INVALIDARG, "got 0x%lx (expected E_INVALIDARG)\n", hr);
1457 static void test_GetRfc1766FromLcid(IMultiLanguage2 *iML2)
1459 CHAR expected[MAX_RFC1766_NAME];
1460 CHAR buffer[MAX_RFC1766_NAME + 1];
1461 DWORD i;
1462 HRESULT hr;
1463 BSTR rfcstr;
1465 for(i = 0; i < ARRAY_SIZE(lcid_table); i++) {
1466 buffer[0] = '\0';
1468 rfcstr = NULL;
1469 hr = IMultiLanguage2_GetRfc1766FromLcid(iML2, lcid_table[i].lcid, &rfcstr);
1470 ok(hr == lcid_table[i].hr,
1471 "#%02ld: HRESULT 0x%lx (expected 0x%lx)\n", i, hr, lcid_table[i].hr);
1473 if (hr != S_OK)
1474 continue; /* no result-string created */
1476 WideCharToMultiByte(CP_ACP, 0, rfcstr, -1, buffer, sizeof(buffer), NULL, NULL);
1477 LCMapStringA(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, lcid_table[i].rfc1766,
1478 lstrlenA(lcid_table[i].rfc1766) + 1, expected, MAX_RFC1766_NAME);
1480 /* IE <6.0 return "x-kok" for LCID 0x457 ("kok") */
1481 ok( (!lstrcmpA(buffer, expected)) ||
1482 broken(!lstrcmpA(buffer, lcid_table[i].broken_rfc)),
1483 "#%02ld: got '%s' (expected '%s')\n", i, buffer, expected);
1485 SysFreeString(rfcstr);
1488 hr = IMultiLanguage2_GetRfc1766FromLcid(iML2, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NULL);
1489 ok(hr == E_INVALIDARG, "got 0x%lx (expected E_INVALIDARG)\n", hr);
1492 static void test_LcidToRfc1766(void)
1494 CHAR expected[MAX_RFC1766_NAME];
1495 CHAR buffer[MAX_RFC1766_NAME * 2];
1496 HRESULT hr;
1497 DWORD i;
1499 for(i = 0; i < ARRAY_SIZE(lcid_table); i++) {
1501 memset(buffer, '#', sizeof(buffer)-1);
1502 buffer[sizeof(buffer)-1] = '\0';
1504 hr = pLcidToRfc1766A(lcid_table[i].lcid, buffer, MAX_RFC1766_NAME);
1506 /* IE <5.0 does not recognize 0x180c (fr-mc) and 0x457 (kok) */
1507 ok( (hr == lcid_table[i].hr) ||
1508 broken(lcid_table[i].broken_lcid && (hr == E_FAIL)),
1509 "#%02ld: HRESULT 0x%lx (expected 0x%lx)\n", i, hr, lcid_table[i].hr);
1511 if (hr != S_OK)
1512 continue;
1514 LCMapStringA(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, lcid_table[i].rfc1766,
1515 lstrlenA(lcid_table[i].rfc1766) + 1, expected, MAX_RFC1766_NAME);
1517 /* IE <6.0 return "x-kok" for LCID 0x457 ("kok") */
1518 /* IE <5.0 return "fr" for LCID 0x180c ("fr-mc") */
1519 ok( (!lstrcmpA(buffer, expected)) ||
1520 broken(!lstrcmpA(buffer, lcid_table[i].broken_rfc)),
1521 "#%02ld: got '%s' (expected '%s')\n", i, buffer, expected);
1525 memset(buffer, '#', sizeof(buffer)-1);
1526 buffer[sizeof(buffer)-1] = '\0';
1527 hr = pLcidToRfc1766A(-1, buffer, MAX_RFC1766_NAME);
1528 ok(hr == E_FAIL, "got 0x%08lx and '%s' (expected E_FAIL)\n", hr, buffer);
1530 hr = pLcidToRfc1766A(LANG_ENGLISH, NULL, MAX_RFC1766_NAME);
1531 ok(hr == E_INVALIDARG, "got 0x%08lx (expected E_INVALIDARG)\n", hr);
1533 memset(buffer, '#', sizeof(buffer)-1);
1534 buffer[sizeof(buffer)-1] = '\0';
1535 hr = pLcidToRfc1766A(LANG_ENGLISH, buffer, -1);
1536 ok(hr == E_INVALIDARG, "got 0x%08lx and '%s' (expected E_INVALIDARG)\n", hr, buffer);
1538 memset(buffer, '#', sizeof(buffer)-1);
1539 buffer[sizeof(buffer)-1] = '\0';
1540 hr = pLcidToRfc1766A(LANG_ENGLISH, buffer, 0);
1541 ok(hr == E_INVALIDARG, "got 0x%08lx and '%s' (expected E_INVALIDARG)\n", hr, buffer);
1544 static void test_GetRfc1766Info(IMultiLanguage2 *iML2)
1546 WCHAR short_broken_name[MAX_LOCALE_NAME];
1547 CHAR rfc1766A[MAX_RFC1766_NAME + 1];
1548 BYTE buffer[sizeof(RFC1766INFO) + 4];
1549 PRFC1766INFO prfc = (RFC1766INFO *) buffer;
1550 HRESULT ret;
1551 DWORD i;
1553 for(i = 0; i < ARRAY_SIZE(info_table); i++) {
1554 memset(buffer, 'x', sizeof(RFC1766INFO) + 2);
1555 buffer[sizeof(buffer) -1] = 0;
1556 buffer[sizeof(buffer) -2] = 0;
1558 ret = IMultiLanguage2_GetRfc1766Info(iML2, info_table[i].lcid, info_table[i].lang, prfc);
1559 WideCharToMultiByte(CP_ACP, 0, prfc->wszRfc1766, -1, rfc1766A, MAX_RFC1766_NAME, NULL, NULL);
1560 ok(ret == S_OK, "#%02ld: got 0x%lx (expected S_OK)\n", i, ret);
1561 ok(prfc->lcid == info_table[i].lcid,
1562 "#%02ld: got 0x%04lx (expected 0x%04lx)\n", i, prfc->lcid, info_table[i].lcid);
1564 ok(!lstrcmpA(rfc1766A, info_table[i].rfc1766),
1565 "#%02ld: got '%s' (expected '%s')\n", i, rfc1766A, info_table[i].rfc1766);
1567 /* Some IE versions truncate an oversized name one character too short */
1568 if (info_table[i].broken_name) {
1569 lstrcpyW(short_broken_name, info_table[i].broken_name);
1570 short_broken_name[MAX_LOCALE_NAME - 2] = 0;
1573 todo_wine_if (info_table[i].todo & TODO_NAME) {
1574 ok( (!lstrcmpW(prfc->wszLocaleName, info_table[i].localename)) ||
1575 (info_table[i].broken_name && (
1576 broken(!lstrcmpW(prfc->wszLocaleName, info_table[i].broken_name)) || /* IE < 6.0 */
1577 broken(!lstrcmpW(prfc->wszLocaleName, short_broken_name)))),
1578 "#%02ld: got %s (expected %s)\n", i,
1579 wine_dbgstr_w(prfc->wszLocaleName), wine_dbgstr_w(info_table[i].localename));
1583 /* SUBLANG_NEUTRAL only allowed for English, Arabic, Chinese */
1584 ret = IMultiLanguage2_GetRfc1766Info(iML2, MAKELANGID(LANG_GERMAN, SUBLANG_NEUTRAL), LANG_ENGLISH, prfc);
1585 ok(ret == E_FAIL, "got 0x%lx (expected E_FAIL)\n", ret);
1587 ret = IMultiLanguage2_GetRfc1766Info(iML2, MAKELANGID(LANG_ITALIAN, SUBLANG_NEUTRAL), LANG_ENGLISH, prfc);
1588 ok(ret == E_FAIL, "got 0x%lx (expected E_FAIL)\n", ret);
1590 /* NULL not allowed */
1591 ret = IMultiLanguage2_GetRfc1766Info(iML2, 0, LANG_ENGLISH, prfc);
1592 ok(ret == E_FAIL, "got 0x%lx (expected E_FAIL)\n", ret);
1594 ret = IMultiLanguage2_GetRfc1766Info(iML2, LANG_ENGLISH, LANG_ENGLISH, NULL);
1595 ok(ret == E_INVALIDARG, "got 0x%lx (expected E_INVALIDARG)\n", ret);
1598 static void test_IMultiLanguage2_ConvertStringFromUnicode(IMultiLanguage2 *iML2)
1600 CHAR dest[MAX_PATH];
1601 CHAR invariate[MAX_PATH];
1602 UINT srcsz, destsz;
1603 HRESULT hr;
1605 static WCHAR src[] = {'a','b','c',0};
1607 memset(invariate, 'x', sizeof(invariate));
1609 /* pSrcStr NULL */
1610 memset(dest, 'x', sizeof(dest));
1611 srcsz = lstrlenW(src) + 1;
1612 destsz = sizeof(dest);
1613 hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, NULL,
1614 &srcsz, dest, &destsz);
1615 ok(hr == S_OK || hr == E_FAIL,"expected S_OK or E_FAIL, got %08lx\n",hr);
1616 if (hr == S_OK)
1618 ok(srcsz == lstrlenW(src) + 1,
1619 "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1621 else if (hr == E_FAIL)
1623 ok(srcsz == 0,
1624 "Expected %u, got %u\n", 0, srcsz);
1627 ok(!memcmp(dest, invariate, sizeof(dest)),
1628 "Expected dest to be unchanged, got %s\n", dest);
1629 ok(destsz == 0, "Expected 0, got %u\n", destsz);
1631 /* pcSrcSize NULL */
1632 memset(dest, 'x', sizeof(dest));
1633 destsz = sizeof(dest);
1634 hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1635 NULL, dest, &destsz);
1636 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1637 ok(!strncmp(dest, "abc", 3),
1638 "Expected first three chars to be \"abc\"\n");
1639 ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1640 "Expected rest of dest to be unchanged, got %s\n", dest);
1641 ok(destsz == lstrlenW(src),
1642 "Expected %u, got %u\n", lstrlenW(src), destsz);
1644 /* both pSrcStr and pcSrcSize NULL */
1645 memset(dest, 'x', sizeof(dest));
1646 destsz = sizeof(dest);
1647 hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, NULL,
1648 NULL, dest, &destsz);
1649 ok(hr == S_OK || hr == E_FAIL, "Expected S_OK or E_FAIL, got %08lx\n", hr);
1650 ok(!memcmp(dest, invariate, sizeof(dest)),
1651 "Expected dest to be unchanged, got %s\n", dest);
1652 ok(destsz == 0, "Expected 0, got %u\n", destsz);
1654 /* pDstStr NULL */
1655 memset(dest, 'x', sizeof(dest));
1656 srcsz = lstrlenW(src) + 1;
1657 destsz = sizeof(dest);
1658 hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1659 &srcsz, NULL, &destsz);
1660 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1661 ok(srcsz == lstrlenW(src) + 1,
1662 "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1663 ok(destsz == lstrlenW(src) + 1,
1664 "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1666 /* pcDstSize NULL */
1667 memset(dest, 'x', sizeof(dest));
1668 hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1669 &srcsz, dest, NULL);
1670 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1671 ok(srcsz == lstrlenW(src) + 1,
1672 "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1673 ok(!memcmp(dest, invariate, sizeof(dest)),
1674 "Expected dest to be unchanged, got %s\n", dest);
1676 /* pcSrcSize is 0 */
1677 memset(dest, 'x', sizeof(dest));
1678 srcsz = 0;
1679 destsz = sizeof(dest);
1680 hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1681 &srcsz, dest, &destsz);
1682 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1683 ok(srcsz == 0, "Expected 0, got %u\n", srcsz);
1684 ok(!memcmp(dest, invariate, sizeof(dest)),
1685 "Expected dest to be unchanged, got %s\n", dest);
1686 ok(destsz == 0, "Expected 0, got %u\n", destsz);
1688 /* pcSrcSize does not include NULL terminator */
1689 memset(dest, 'x', sizeof(dest));
1690 srcsz = lstrlenW(src);
1691 destsz = sizeof(dest);
1692 hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1693 &srcsz, dest, &destsz);
1694 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1695 ok(srcsz == lstrlenW(src),
1696 "Expected %u, got %u\n", lstrlenW(src), srcsz);
1697 ok(!strncmp(dest, "abc", 3), "Expected first three chars to be \"abc\"\n");
1698 ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1699 "Expected rest of dest to be unchanged, got %s\n", dest);
1700 ok(destsz == lstrlenW(src),
1701 "Expected %u, got %u\n", lstrlenW(src), destsz);
1703 /* pcSrcSize includes NULL terminator */
1704 memset(dest, 'x', sizeof(dest));
1705 srcsz = lstrlenW(src) + 1;
1706 destsz = sizeof(dest);
1707 hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1708 &srcsz, dest, &destsz);
1709 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1710 ok(srcsz == lstrlenW(src) + 1, "Expected 3, got %u\n", srcsz);
1711 ok(!lstrcmpA(dest, "abc"), "Expected \"abc\", got \"%s\"\n", dest);
1712 ok(destsz == lstrlenW(src) + 1,
1713 "Expected %u, got %u\n", lstrlenW(src) + 1, destsz);
1715 /* pcSrcSize is -1 */
1716 memset(dest, 'x', sizeof(dest));
1717 srcsz = -1;
1718 destsz = sizeof(dest);
1719 hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1720 &srcsz, dest, &destsz);
1721 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1722 ok(srcsz == lstrlenW(src),
1723 "Expected %u, got %u\n", lstrlenW(src), srcsz);
1724 ok(!strncmp(dest, "abc", 3), "Expected first three chars to be \"abc\"\n");
1725 ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1726 "Expected rest of dest to be unchanged, got %s\n", dest);
1727 ok(destsz == lstrlenW(src),
1728 "Expected %u, got %u\n", lstrlenW(src), destsz);
1730 /* pcDstSize is 0 */
1731 memset(dest, 'x', sizeof(dest));
1732 srcsz = lstrlenW(src) + 1;
1733 destsz = 0;
1734 hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1735 &srcsz, dest, &destsz);
1736 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1737 ok(srcsz == lstrlenW(src) + 1,
1738 "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1739 ok(!memcmp(dest, invariate, sizeof(dest)),
1740 "Expected dest to be unchanged, got %s\n", dest);
1741 ok(destsz == lstrlenW(src) + 1,
1742 "Expected %u, got %u\n", lstrlenW(src) + 1, destsz);
1744 /* pcDstSize is not large enough */
1745 memset(dest, 'x', sizeof(dest));
1746 srcsz = lstrlenW(src) + 1;
1747 destsz = lstrlenW(src);
1748 hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1749 &srcsz, dest, &destsz);
1750 ok(hr == E_FAIL, "Expected E_FAIL, got %08lx\n", hr);
1751 ok(srcsz == 0, "Expected 0, got %u\n", srcsz);
1752 ok(!strncmp(dest, "abc", 3), "Expected first three chars to be \"abc\"\n");
1753 ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1754 "Expected rest of dest to be unchanged, got %s\n", dest);
1755 ok(destsz == 0, "Expected 0, got %u\n", srcsz);
1757 /* pcDstSize (bytes) does not leave room for NULL terminator */
1758 memset(dest, 'x', sizeof(dest));
1759 srcsz = lstrlenW(src) + 1;
1760 destsz = lstrlenW(src) * sizeof(WCHAR);
1761 hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1762 &srcsz, dest, &destsz);
1763 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1764 ok(srcsz == lstrlenW(src) + 1,
1765 "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1766 ok(!lstrcmpA(dest, "abc"), "Expected \"abc\", got \"%s\"\n", dest);
1767 ok(destsz == lstrlenW(src) + 1,
1768 "Expected %u, got %u\n", lstrlenW(src) + 1, destsz);
1771 static void test_ConvertINetUnicodeToMultiByte(void)
1773 CHAR dest[MAX_PATH];
1774 CHAR invariate[MAX_PATH];
1775 INT srcsz, destsz;
1776 HRESULT hr;
1778 static WCHAR src[] = {'a','b','c',0};
1780 memset(invariate, 'x', sizeof(invariate));
1782 /* lpSrcStr NULL */
1783 memset(dest, 'x', sizeof(dest));
1784 srcsz = lstrlenW(src) + 1;
1785 destsz = sizeof(dest);
1786 hr = pConvertINetUnicodeToMultiByte(NULL, 1252, NULL, &srcsz, dest, &destsz);
1787 ok(hr == S_OK || hr == E_FAIL, "Expected S_OK or E_FAIL, got %08lx\n", hr);
1788 if (hr == S_OK)
1789 ok(srcsz == lstrlenW(src) + 1,
1790 "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1791 else if (hr == E_FAIL)
1792 ok(srcsz == 0,
1793 "Expected %u, got %u\n", 0, srcsz);
1794 ok(!memcmp(dest, invariate, sizeof(dest)),
1795 "Expected dest to be unchanged, got %s\n", dest);
1796 ok(destsz == 0, "Expected 0, got %u\n", destsz);
1798 /* lpnWideCharCount NULL */
1799 memset(dest, 'x', sizeof(dest));
1800 destsz = sizeof(dest);
1801 hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, NULL, dest, &destsz);
1802 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1803 ok(!strncmp(dest, "abc", 3),
1804 "Expected first three chars to be \"abc\"\n");
1805 ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1806 "Expected rest of dest to be unchanged, got %s\n", dest);
1807 ok(destsz == lstrlenW(src),
1808 "Expected %u, got %u\n", lstrlenW(src), destsz);
1810 /* both lpSrcStr and lpnWideCharCount NULL */
1811 memset(dest, 'x', sizeof(dest));
1812 destsz = sizeof(dest);
1813 hr = pConvertINetUnicodeToMultiByte(NULL, 1252, NULL, NULL, dest, &destsz);
1814 ok(hr == S_OK || hr == E_FAIL, "Expected S_OK or E_FAIL, got %08lx\n", hr);
1815 ok(!memcmp(dest, invariate, sizeof(dest)),
1816 "Expected dest to be unchanged, got %s\n", dest);
1817 ok(destsz == 0, "Expected 0, got %u\n", destsz);
1819 /* lpDstStr NULL */
1820 memset(dest, 'x', sizeof(dest));
1821 srcsz = lstrlenW(src) + 1;
1822 destsz = sizeof(dest);
1823 hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, NULL, &destsz);
1824 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1825 ok(srcsz == lstrlenW(src) + 1,
1826 "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1827 ok(destsz == lstrlenW(src) + 1,
1828 "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1830 /* lpnMultiCharCount NULL */
1831 memset(dest, 'x', sizeof(dest));
1832 hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, NULL);
1833 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1834 ok(srcsz == lstrlenW(src) + 1,
1835 "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1836 ok(!memcmp(dest, invariate, sizeof(dest)),
1837 "Expected dest to be unchanged, got %s\n", dest);
1839 /* lpnWideCharCount is 0 */
1840 memset(dest, 'x', sizeof(dest));
1841 srcsz = 0;
1842 destsz = sizeof(dest);
1843 hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, &destsz);
1844 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1845 ok(srcsz == 0, "Expected 0, got %u\n", srcsz);
1846 ok(!memcmp(dest, invariate, sizeof(dest)),
1847 "Expected dest to be unchanged, got %s\n", dest);
1848 ok(destsz == 0, "Expected 0, got %u\n", destsz);
1850 /* lpnWideCharCount does not include NULL terminator */
1851 memset(dest, 'x', sizeof(dest));
1852 srcsz = lstrlenW(src);
1853 destsz = sizeof(dest);
1854 hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, &destsz);
1855 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1856 ok(srcsz == lstrlenW(src),
1857 "Expected %u, got %u\n", lstrlenW(src), srcsz);
1858 ok(!strncmp(dest, "abc", 3), "Expected first three chars to be \"abc\"\n");
1859 ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1860 "Expected rest of dest to be unchanged, got %s\n", dest);
1861 ok(destsz == lstrlenW(src),
1862 "Expected %u, got %u\n", lstrlenW(src), destsz);
1864 /* lpnWideCharCount includes NULL terminator */
1865 memset(dest, 'x', sizeof(dest));
1866 srcsz = lstrlenW(src) + 1;
1867 destsz = sizeof(dest);
1868 hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, &destsz);
1869 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1870 ok(srcsz == lstrlenW(src) + 1, "Expected 3, got %u\n", srcsz);
1871 ok(!lstrcmpA(dest, "abc"), "Expected \"abc\", got \"%s\"\n", dest);
1872 ok(destsz == lstrlenW(src) + 1,
1873 "Expected %u, got %u\n", lstrlenW(src) + 1, destsz);
1875 /* lpnWideCharCount is -1 */
1876 memset(dest, 'x', sizeof(dest));
1877 srcsz = -1;
1878 destsz = sizeof(dest);
1879 hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, &destsz);
1880 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1881 ok(srcsz == lstrlenW(src),
1882 "Expected %u, got %u\n", lstrlenW(src), srcsz);
1883 ok(!strncmp(dest, "abc", 3), "Expected first three chars to be \"abc\"\n");
1884 ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1885 "Expected rest of dest to be unchanged, got %s\n", dest);
1886 ok(destsz == lstrlenW(src),
1887 "Expected %u, got %u\n", lstrlenW(src), destsz);
1889 /* lpnMultiCharCount is 0 */
1890 memset(dest, 'x', sizeof(dest));
1891 srcsz = lstrlenW(src) + 1;
1892 destsz = 0;
1893 hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, &destsz);
1894 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1895 ok(srcsz == lstrlenW(src) + 1,
1896 "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1897 ok(!memcmp(dest, invariate, sizeof(dest)),
1898 "Expected dest to be unchanged, got %s\n", dest);
1899 ok(destsz == lstrlenW(src) + 1,
1900 "Expected %u, got %u\n", lstrlenW(src) + 1, destsz);
1902 /* lpnMultiCharCount is not large enough */
1903 memset(dest, 'x', sizeof(dest));
1904 srcsz = lstrlenW(src) + 1;
1905 destsz = lstrlenW(src);
1906 hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, &destsz);
1907 ok(hr == E_FAIL, "Expected E_FAIL, got %08lx\n", hr);
1908 ok(srcsz == 0, "Expected 0, got %u\n", srcsz);
1909 ok(!strncmp(dest, "abc", 3), "Expected first three chars to be \"abc\"\n");
1910 ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1911 "Expected rest of dest to be unchanged, got %s\n", dest);
1912 ok(destsz == 0, "Expected 0, got %u\n", srcsz);
1914 /* lpnMultiCharCount (bytes) does not leave room for NULL terminator */
1915 memset(dest, 'x', sizeof(dest));
1916 srcsz = lstrlenW(src) + 1;
1917 destsz = lstrlenW(src) * sizeof(WCHAR);
1918 hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, &destsz);
1919 ok(hr == S_OK, "Expected S_OK, got %08lx\n", hr);
1920 ok(srcsz == lstrlenW(src) + 1,
1921 "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1922 ok(!lstrcmpA(dest, "abc"), "Expected \"abc\", got \"%s\"\n", dest);
1923 ok(destsz == lstrlenW(src) + 1,
1924 "Expected %u, got %u\n", lstrlenW(src) + 1, destsz);
1927 static void test_JapaneseConversion(void)
1929 /* Data */
1930 static WCHAR unc_jp[9][12] = {
1931 {9,0x31,0x20,0x3042,0x3044,0x3046,0x3048,0x304a,0x000d,0x000a},
1932 {9,0x31,0x20,0x30a2,0x30a4,0x30a6,0x30a8,0x30aa,0x000d,0x000a},
1933 {9,0x31,0x20,0xff71,0xff72,0xff73,0xff74,0xff75,0x000d,0x000a},
1934 {9,0x31,0x20,0x3041,0x3043,0x3045,0x3047,0x3049,0x000d,0x000a},
1935 {9,0x31,0x20,0x30a1,0x30a3,0x30a5,0x30a7,0x30a9,0x000d,0x000a},
1936 {9,0x31,0x20,0xff67,0xff68,0xff69,0xff6a,0xff6b,0x000d,0x000a},
1937 {9,0x31,0x20,0x300c,0x65e5,0x672c,0x8a9e,0x300d,0x000d,0x000a},
1938 {7,0x31,0x20,0x25c7,0x25c7,0x3012,0x000d,0x000a},
1939 {11,0x31,0x20,0x203b,0x3010,0x0074,0x0065,0x0073,0x0074,0x3011,0x000d,0x000a}
1941 static CHAR jis_jp[9][27] = {
1942 {20,0x31,0x20,0x1b,0x24,0x42,0x24,0x22,0x24,0x24,0x24,0x26,0x24,0x28,
1943 0x24,0x2a,0x1b,0x28,0x42,0x0d,0x0a},
1944 {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x22,0x25,0x24,0x25,0x26,0x25,0x28,
1945 0x25,0x2a,0x1b,0x28,0x42,0x0d,0x0a},
1946 {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x22,0x25,0x24,0x25,0x26,0x25,0x28,
1947 0x25,0x2a,0x1b,0x28,0x42,0x0d,0x0a},
1948 {20,0x31,0x20,0x1b,0x24,0x42,0x24,0x21,0x24,0x23,0x24,0x25,0x24,0x27,
1949 0x24,0x29,0x1b,0x28,0x42,0x0d,0x0a},
1950 {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x21,0x25,0x23,0x25,0x25,0x25,0x27,
1951 0x25,0x29,0x1b,0x28,0x42,0x0d,0x0a},
1952 {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x21,0x25,0x23,0x25,0x25,0x25,0x27,
1953 0x25,0x29,0x1b,0x28,0x42,0x0d,0x0a},
1954 {20,0x31,0x20,0x1b,0x24,0x42,0x21,0x56,0x46,0x7c,0x4b,0x5c,0x38,0x6c,
1955 0x21,0x57,0x1b,0x28,0x42,0x0d,0x0a},
1956 {16,0x31,0x20,0x1b,0x24,0x42,0x21,0x7e,0x21,0x7e,0x22,0x29,0x1b,0x28,
1957 0x42,0x0d,0x0a},
1958 {26,0x31,0x20,0x1b,0x24,0x42,0x22,0x28,0x21,0x5a,0x1b,0x28,0x42,0x74,
1959 0x65,0x73,0x74,0x1b,0x24,0x42,0x21,0x5b,0x1b,0x28,0x42,0x0d,0x0a}
1961 static CHAR sjis_jp[9][15] = {
1962 {14,0x31,0x20,0x82,0xa0,0x82,0xa2,0x82,0xa4,0x82,0xa6,0x82,0xa8,0x0d,0x0a},
1963 {14,0x31,0x20,0x83,0x41,0x83,0x43,0x83,0x45,0x83,0x47,0x83,0x49,0x0d,0x0a},
1964 {9,0x31,0x20,0xb1,0xb2,0xb3,0xb4,0xb5,0x0d,0x0a},
1965 {14,0x31,0x20,0x82,0x9f,0x82,0xa1,0x82,0xa3,0x82,0xa5,0x82,0xa7,0x0d,0x0a},
1966 {14,0x31,0x20,0x83,0x40,0x83,0x42,0x83,0x44,0x83,0x46,0x83,0x48,0x0d,0x0a},
1967 {9,0x31,0x20,0xa7,0xa8,0xa9,0xaa,0xab,0x0d,0x0a},
1968 {14,0x31,0x20,0x81,0x75,0x93,0xfa,0x96,0x7b,0x8c,0xea,0x81,0x76,0x0d,0x0a},
1969 {10,0x31,0x20,0x81,0x9e,0x81,0x9e,0x81,0xa7,0x0d,0x0a},
1970 {14,0x31,0x20,0x81,0xa6,0x81,0x79,0x74,0x65,0x73,0x74,0x81,0x7a,0x0d,0x0a}
1972 static CHAR euc_jp[9][15] = {
1973 {14,0x31,0x20,0xa4,0xa2,0xa4,0xa4,0xa4,0xa6,0xa4,0xa8,0xa4,0xaa,0x0d,0x0a},
1974 {14,0x31,0x20,0xa5,0xa2,0xa5,0xa4,0xa5,0xa6,0xa5,0xa8,0xa5,0xaa,0x0d,0x0a},
1975 {14,0x31,0x20,0x8e,0xb1,0x8e,0xb2,0x8e,0xb3,0x8e,0xb4,0x8e,0xb5,0x0d,0x0a},
1976 {14,0x31,0x20,0xa4,0xa1,0xa4,0xa3,0xa4,0xa5,0xa4,0xa7,0xa4,0xa9,0x0d,0x0a},
1977 {14,0x31,0x20,0xa5,0xa1,0xa5,0xa3,0xa5,0xa5,0xa5,0xa7,0xa5,0xa9,0x0d,0x0a},
1978 {14,0x31,0x20,0x8e,0xa7,0x8e,0xa8,0x8e,0xa9,0x8e,0xaa,0x8e,0xab,0x0d,0x0a},
1979 {14,0x31,0x20,0xa1,0xd6,0xc6,0xfc,0xcb,0xdc,0xb8,0xec,0xa1,0xd7,0x0d,0x0a},
1980 {10,0x31,0x20,0xa1,0xfe,0xa1,0xfe,0xa2,0xa9,0x0d,0x0a},
1981 {14,0x31,0x20,0xa2,0xa8,0xa1,0xda,0x74,0x65,0x73,0x74,0xa1,0xdb,0x0d,0x0a}
1984 INT srcsz, destsz;
1985 INT i;
1986 HRESULT hr;
1987 CHAR output[30];
1988 WCHAR outputW[30];
1989 int outlen;
1991 /* test unc->jis */
1992 for (i = 0; i < 9; i++)
1994 int j;
1995 destsz = 30;
1996 outlen = jis_jp[i][0];
1997 srcsz = unc_jp[i][0];
1998 hr = pConvertINetUnicodeToMultiByte(NULL, 50220, &unc_jp[i][1], &srcsz, output, &destsz);
1999 if (hr == S_FALSE)
2001 skip("Code page identifier 50220 is not supported\n");
2002 break;
2004 ok(hr == S_OK,"(%i) Expected S_OK, got %08lx\n", i, hr);
2005 ok(destsz == outlen, "(%i) Expected %i, got %i\n",i,outlen,destsz);
2006 ok(srcsz == unc_jp[i][0],"(%i) Expected %i, got %i\n",i,unc_jp[i][0],srcsz);
2007 ok(memcmp(output,&jis_jp[i][1],destsz)==0,"(%i) Strings do not match\n",i);
2009 /* and back */
2010 srcsz = outlen;
2011 destsz = 30;
2012 hr = pConvertINetMultiByteToUnicode(NULL, 50220, output, &srcsz, outputW,&destsz);
2015 * JIS does not have hankata so it get automatically converted to
2016 * zenkata. this means that strings 1 and 2 are identical as well as
2017 * strings 4 and 5.
2019 j = i;
2020 if (i == 2) j = 1;
2021 if (i == 5) j = 4;
2023 ok(hr == S_OK,"(%i) Expected S_OK, got %08lx\n",i, hr);
2024 ok(destsz == unc_jp[j][0],"(%i) Expected %i, got %i\n",i,unc_jp[j][0],destsz);
2025 ok(srcsz == outlen,"(%i) Expected %i, got %i\n",i,outlen,srcsz);
2026 ok(memcmp(outputW,&unc_jp[j][1],destsz)==0,"(%i) Strings do not match\n",i);
2029 /* test unc->sjis */
2030 for (i = 0; i < 9; i++)
2032 destsz = 30;
2033 outlen = sjis_jp[i][0];
2034 srcsz = unc_jp[i][0];
2036 hr = pConvertINetUnicodeToMultiByte(NULL, 932, &unc_jp[i][1], &srcsz, output, &destsz);
2037 if (hr == S_FALSE)
2039 skip("Code page identifier 932 is not supported\n");
2040 break;
2042 ok(hr == S_OK,"(%i) Expected S_OK, got %08lx\n",i,hr);
2043 ok(destsz == outlen,"(%i) Expected %i, got %i\n",i,outlen,destsz);
2044 ok(srcsz == unc_jp[i][0],"(%i) Expected %i, got %i\n",i,unc_jp[i][0],srcsz);
2045 ok(memcmp(output,&sjis_jp[i][1],outlen)==0,"(%i) Strings do not match\n",i);
2047 srcsz = outlen;
2048 destsz = 30;
2049 hr = pConvertINetMultiByteToUnicode(NULL, 932, output, &srcsz, outputW,&destsz);
2051 ok(hr == S_OK,"(%i) Expected S_OK, got %08lx\n", i, hr);
2052 ok(destsz == unc_jp[i][0],"(%i) Expected %i, got %i\n",i,unc_jp[i][0],destsz);
2053 ok(srcsz == outlen,"(%i) Expected %i, got %i\n",i,outlen,srcsz);
2054 ok(memcmp(outputW,&unc_jp[i][1],destsz)==0,"(%i) Strings do not match\n",i);
2057 /* test unc->euc */
2058 for (i = 0; i < 9; i++)
2060 destsz = 30;
2061 outlen = euc_jp[i][0];
2062 srcsz = unc_jp[i][0];
2064 hr = pConvertINetUnicodeToMultiByte(NULL, 51932, &unc_jp[i][1], &srcsz, output, &destsz);
2065 if (hr == S_FALSE)
2067 skip("Code page identifier 51932 is not supported\n");
2068 break;
2070 ok(hr == S_OK, "(%i) Expected S_OK, got %08lx\n",i,hr);
2071 ok(destsz == outlen, "(%i) Expected %i, got %i\n",i,outlen,destsz);
2072 ok(srcsz == unc_jp[i][0],"(%i) Expected %i, got %i\n",i,unc_jp[i][0],destsz);
2073 ok(memcmp(output,&euc_jp[i][1],outlen)==0,"(%i) Strings do not match\n",i);
2075 srcsz = outlen;
2076 destsz = 30;
2077 hr = pConvertINetMultiByteToUnicode(NULL, 51932, output, &srcsz, outputW,&destsz);
2079 ok(hr == S_OK,"(%i) Expected S_OK, got %08lx\n",i,hr);
2080 ok(destsz == unc_jp[i][0],"(%i) Expected %i, got %i\n",i,unc_jp[i][0],destsz);
2081 ok(srcsz == outlen,"(%i) Expected %i, got %i\n",i,outlen,srcsz);
2082 ok(memcmp(outputW,&unc_jp[i][1],destsz)==0,"(%i) Strings do not match\n",i);
2085 /* Japanese autodetect */
2086 i = 0;
2087 destsz = 30;
2088 srcsz = jis_jp[i][0];
2089 hr = pConvertINetMultiByteToUnicode(NULL, 50932, &jis_jp[i][1], &srcsz, outputW, &destsz);
2090 if (hr == S_FALSE)
2092 skip("Code page identifier 50932 is not supported\n");
2093 return;
2095 ok(hr == S_OK,"(%i) Expected S_OK, got %08lx\n",i,hr);
2096 ok(destsz == unc_jp[i][0],"(%i) Expected %i, got %i\n",i,unc_jp[i][0],destsz);
2097 ok(srcsz == jis_jp[i][0],"(%i) Expected %i, got %i\n",i,jis_jp[i][0],srcsz);
2098 ok(memcmp(outputW,&unc_jp[i][1],destsz)==0,"(%i) Strings do not match\n",i);
2100 i = 1;
2101 destsz = 30;
2102 srcsz = sjis_jp[i][0];
2103 hr = pConvertINetMultiByteToUnicode(NULL, 50932, &sjis_jp[i][1], &srcsz, outputW, &destsz);
2104 ok(hr == S_OK,"(%i) Expected S_OK, got %08lx\n",i,hr);
2105 ok(destsz == unc_jp[i][0],"(%i) Expected %i, got %i\n",i,unc_jp[i][0],destsz);
2106 ok(srcsz == sjis_jp[i][0],"(%i) Expected %i, got %i\n",i,sjis_jp[i][0],srcsz);
2107 ok(memcmp(outputW,&unc_jp[i][1],destsz)==0,"(%i) Strings do not match\n",i);
2110 static void test_GetScriptFontInfo(IMLangFontLink2 *font_link)
2112 HRESULT hr;
2113 UINT nfonts;
2114 SCRIPTFONTINFO sfi[1];
2116 nfonts = 0;
2117 hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidAsciiLatin, 0, &nfonts, NULL);
2118 ok(hr == S_OK, "GetScriptFontInfo failed %lu\n", GetLastError());
2119 ok(nfonts, "unexpected result\n");
2121 nfonts = 0;
2122 hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidAsciiLatin, SCRIPTCONTF_FIXED_FONT, &nfonts, NULL);
2123 ok(hr == S_OK, "GetScriptFontInfo failed %lu\n", GetLastError());
2124 ok(nfonts, "unexpected result\n");
2126 nfonts = 0;
2127 hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidAsciiLatin, SCRIPTCONTF_PROPORTIONAL_FONT, &nfonts, NULL);
2128 ok(hr == S_OK, "GetScriptFontInfo failed %lu\n", GetLastError());
2129 ok(nfonts, "unexpected result\n");
2131 nfonts = 1;
2132 memset(sfi, 0, sizeof(sfi));
2133 hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidAsciiLatin, SCRIPTCONTF_FIXED_FONT, &nfonts, sfi);
2134 ok(hr == S_OK, "GetScriptFontInfo failed %lu\n", GetLastError());
2135 ok(nfonts == 1, "got %u, expected 1\n", nfonts);
2136 ok(sfi[0].scripts != 0, "unexpected result\n");
2137 ok(sfi[0].wszFont[0], "unexpected result\n");
2139 nfonts = 1;
2140 memset(sfi, 0, sizeof(sfi));
2141 hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidAsciiLatin, SCRIPTCONTF_PROPORTIONAL_FONT, &nfonts, sfi);
2142 ok(hr == S_OK, "GetScriptFontInfo failed %lu\n", GetLastError());
2143 ok(nfonts == 1, "got %u, expected 1\n", nfonts);
2144 ok(sfi[0].scripts != 0, "unexpected result\n");
2145 ok(sfi[0].wszFont[0], "unexpected result\n");
2148 static void test_CodePageToScriptID(IMLangFontLink2 *font_link)
2150 HRESULT hr;
2151 UINT i;
2152 SCRIPT_ID sid;
2153 static const struct
2155 UINT cp;
2156 SCRIPT_ID sid;
2157 HRESULT hr;
2159 cp_sid[] =
2161 {874, sidThai},
2162 {932, sidKana},
2163 {936, sidHan},
2164 {949, sidHangul},
2165 {950, sidBopomofo},
2166 {1250, sidAsciiLatin},
2167 {1251, sidCyrillic},
2168 {1252, sidAsciiLatin},
2169 {1253, sidGreek},
2170 {1254, sidAsciiLatin},
2171 {1255, sidHebrew},
2172 {1256, sidArabic},
2173 {1257, sidAsciiLatin},
2174 {1258, sidAsciiLatin},
2175 {CP_UNICODE, 0, E_FAIL}
2178 for (i = 0; i < ARRAY_SIZE(cp_sid); i++)
2180 hr = IMLangFontLink2_CodePageToScriptID(font_link, cp_sid[i].cp, &sid);
2181 ok(hr == cp_sid[i].hr, "%u CodePageToScriptID failed 0x%08lx %lu\n", i, hr, GetLastError());
2182 if (SUCCEEDED(hr))
2184 ok(sid == cp_sid[i].sid,
2185 "%u got sid %u for codepage %u, expected %u\n", i, sid, cp_sid[i].cp, cp_sid[i].sid);
2190 static void test_GetFontUnicodeRanges(IMLangFontLink2 *font_link)
2192 HRESULT hr;
2193 UINT count;
2194 HFONT hfont, old_hfont;
2195 LOGFONTA lf;
2196 HDC hdc;
2197 UNICODERANGE *ur;
2199 hdc = CreateCompatibleDC(0);
2200 memset(&lf, 0, sizeof(lf));
2201 lstrcpyA(lf.lfFaceName, "Arial");
2202 hfont = CreateFontIndirectA(&lf);
2203 old_hfont = SelectObject(hdc, hfont);
2205 count = 0;
2206 hr = IMLangFontLink2_GetFontUnicodeRanges(font_link, NULL, &count, NULL);
2207 ok(hr == E_FAIL, "expected E_FAIL, got 0x%08lx\n", hr);
2209 hr = IMLangFontLink2_GetFontUnicodeRanges(font_link, hdc, NULL, NULL);
2210 ok(hr == E_INVALIDARG, "expected E_FAIL, got 0x%08lx\n", hr);
2212 count = 0;
2213 hr = IMLangFontLink2_GetFontUnicodeRanges(font_link, hdc, &count, NULL);
2214 ok(hr == S_OK, "expected S_OK, got 0x%08lx\n", hr);
2215 ok(count, "expected count > 0\n");
2217 ur = HeapAlloc(GetProcessHeap(), 0, sizeof(*ur) * count);
2219 hr = IMLangFontLink2_GetFontUnicodeRanges(font_link, hdc, &count, ur);
2220 ok(hr == S_OK, "expected S_OK, got 0x%08lx\n", hr);
2222 count--;
2223 hr = IMLangFontLink2_GetFontUnicodeRanges(font_link, hdc, &count, ur);
2224 ok(hr == S_OK, "expected S_OK, got 0x%08lx\n", hr);
2226 HeapFree(GetProcessHeap(), 0, ur);
2228 SelectObject(hdc, old_hfont);
2229 DeleteObject(hfont);
2230 DeleteDC(hdc);
2233 static void test_IsCodePageInstallable(IMultiLanguage2 *ml2)
2235 UINT i;
2236 HRESULT hr;
2238 for (i = 0; i < 1000; i++)
2240 hr = IMultiLanguage2_IsCodePageInstallable(ml2, i);
2242 /* it would be better to use IMultiLanguage2_ValidateCodePageEx here but that brings
2243 * up an installation dialog on some platforms, even when specifying CPIOD_PEEK.
2245 if (IsValidCodePage(i))
2246 ok(hr == S_OK ||
2247 broken(hr == S_FALSE) || /* win2k */
2248 broken(hr == E_INVALIDARG), /* win2k */
2249 "code page %u is valid but not installable 0x%08lx\n", i, hr);
2253 static void test_GetGlobalFontLinkObject(void)
2255 HRESULT ret;
2256 void *unknown;
2258 ret = GetGlobalFontLinkObject(NULL);
2259 ok(ret == E_INVALIDARG, "expected E_INVALIDARG got %#lx\n", ret);
2261 unknown = (void *)0xdeadbeef;
2262 ret = GetGlobalFontLinkObject(&unknown);
2263 todo_wine {
2264 ok(ret == S_OK, "expected S_OK got %#lx\n", ret);
2265 ok(unknown != NULL && unknown != (void *)0xdeadbeef,
2266 "GetGlobalFontLinkObject() returned %p\n", unknown);
2270 static void test_IMLangConvertCharset(IMultiLanguage *ml)
2272 IMLangConvertCharset *convert;
2273 WCHAR strW[] = {'a','b','c','d',0};
2274 UINT cp, src_size, dst_size;
2275 char strA[] = "abcd";
2276 WCHAR buffW[20];
2277 HRESULT hr;
2279 hr = IMultiLanguage_CreateConvertCharset(ml, CP_ACP, CP_UTF8, 0, &convert);
2280 todo_wine
2281 ok(hr == S_FALSE, "expected S_FALSE got 0x%08lx\n", hr);
2283 hr = IMLangConvertCharset_GetSourceCodePage(convert, NULL);
2284 ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr);
2286 cp = CP_UTF8;
2287 hr = IMLangConvertCharset_GetSourceCodePage(convert, &cp);
2288 ok(hr == S_OK, "expected S_OK got 0x%08lx\n", hr);
2289 ok(cp == CP_ACP, "got %d\n", cp);
2291 hr = IMLangConvertCharset_GetDestinationCodePage(convert, NULL);
2292 ok(hr == E_INVALIDARG, "got 0x%08lx\n", hr);
2294 cp = CP_ACP;
2295 hr = IMLangConvertCharset_GetDestinationCodePage(convert, &cp);
2296 ok(hr == S_OK, "expected S_OK got 0x%08lx\n", hr);
2297 ok(cp == CP_UTF8, "got %d\n", cp);
2299 /* DoConversionToUnicode */
2300 hr = IMLangConvertCharset_Initialize(convert, CP_UTF8, CP_UNICODE, 0);
2301 ok(hr == S_OK, "expected S_OK got 0x%08lx\n", hr);
2303 hr = IMLangConvertCharset_DoConversionToUnicode(convert, NULL, NULL, NULL, NULL);
2304 ok(hr == E_FAIL || broken(hr == S_OK) /* win2k */, "got 0x%08lx\n", hr);
2306 src_size = -1;
2307 dst_size = 20;
2308 buffW[0] = 0;
2309 buffW[4] = 4;
2310 hr = IMLangConvertCharset_DoConversionToUnicode(convert, strA, &src_size, buffW, &dst_size);
2311 ok(hr == S_OK, "got 0x%08lx\n", hr);
2312 ok(!memcmp(buffW, strW, 4*sizeof(WCHAR)), "got converted string %s\n", wine_dbgstr_wn(buffW, dst_size));
2313 ok(dst_size == 4, "got %d\n", dst_size);
2314 ok(buffW[4] == 4, "got %d\n", buffW[4]);
2315 ok(src_size == 4, "got %d\n", src_size);
2317 src_size = -1;
2318 dst_size = 0;
2319 buffW[0] = 1;
2320 hr = IMLangConvertCharset_DoConversionToUnicode(convert, strA, &src_size, buffW, &dst_size);
2321 ok(hr == S_OK, "got 0x%08lx\n", hr);
2322 ok(buffW[0] == 1, "got %d\n", buffW[0]);
2323 ok(dst_size == 4, "got %d\n", dst_size);
2324 ok(src_size == 4, "got %d\n", src_size);
2326 hr = IMLangConvertCharset_Initialize(convert, CP_UNICODE, CP_UNICODE, 0);
2327 ok(hr == S_OK, "expected S_OK got 0x%08lx\n", hr);
2329 IMLangConvertCharset_Release(convert);
2332 static const char stream_data[] = "VCARD2.1test;test";
2333 static ULONG stream_pos;
2335 static HRESULT WINAPI stream_QueryInterface(IStream *iface, REFIID riid, void **obj)
2337 ok(FALSE, "unexpected call\n");
2338 return E_NOINTERFACE;
2341 static ULONG WINAPI stream_AddRef(IStream *iface)
2343 ok(FALSE, "unexpected call\n");
2344 return 2;
2347 static ULONG WINAPI stream_Release(IStream *iface)
2349 ok(FALSE, "unexpected call\n");
2350 return 1;
2353 static HRESULT WINAPI stream_Read(IStream *iface, void *buf, ULONG len, ULONG *read)
2355 ULONG size;
2357 if (stream_pos == sizeof(stream_data) - 1)
2359 *read = 0;
2360 return S_FALSE;
2362 size = min(sizeof(stream_data) - 1 - stream_pos, len);
2363 memcpy(buf, stream_data + stream_pos, size);
2364 stream_pos += size;
2365 *read = size;
2366 return S_OK;
2369 static HRESULT WINAPI stream_Write(IStream *iface, const void *buf, ULONG len, ULONG *written)
2371 ok(FALSE, "unexpected call\n");
2372 return E_NOTIMPL;
2375 static HRESULT WINAPI stream_Seek(IStream *iface, LARGE_INTEGER move, DWORD origin,
2376 ULARGE_INTEGER *newpos)
2378 if (origin == STREAM_SEEK_SET)
2379 stream_pos = move.QuadPart;
2380 else if (origin == STREAM_SEEK_CUR)
2381 stream_pos += move.QuadPart;
2382 else if (origin == STREAM_SEEK_END)
2383 stream_pos = sizeof(stream_data) - 1 - move.QuadPart;
2385 if (newpos) newpos->QuadPart = stream_pos;
2386 return S_OK;
2389 static HRESULT WINAPI stream_SetSize(IStream *iface, ULARGE_INTEGER newsize)
2391 ok(FALSE, "unexpected call\n");
2392 return E_NOTIMPL;
2395 static HRESULT WINAPI stream_CopyTo(IStream *iface, IStream *stream, ULARGE_INTEGER len,
2396 ULARGE_INTEGER *read, ULARGE_INTEGER *written)
2398 ok(FALSE, "unexpected call\n");
2399 return E_NOTIMPL;
2402 static HRESULT WINAPI stream_Commit(IStream *iface, DWORD flags)
2404 ok(FALSE, "unexpected call\n");
2405 return E_NOTIMPL;
2408 static HRESULT WINAPI stream_Revert(IStream *iface)
2410 ok(FALSE, "unexpected call\n");
2411 return E_NOTIMPL;
2414 static HRESULT WINAPI stream_LockRegion(IStream *iface, ULARGE_INTEGER offset,
2415 ULARGE_INTEGER len, DWORD locktype)
2417 ok(FALSE, "unexpected call\n");
2418 return E_NOTIMPL;
2421 static HRESULT WINAPI stream_UnlockRegion(IStream *iface, ULARGE_INTEGER offset,
2422 ULARGE_INTEGER len, DWORD locktype)
2424 ok(FALSE, "unexpected call\n");
2425 return E_NOTIMPL;
2428 static HRESULT WINAPI stream_Stat(IStream *iface, STATSTG *stg, DWORD flag)
2430 ok(FALSE, "unexpected call\n");
2431 return E_NOTIMPL;
2434 static HRESULT WINAPI stream_Clone(IStream *iface, IStream **stream)
2436 ok(FALSE, "unexpected call\n");
2437 return E_NOTIMPL;
2440 static const IStreamVtbl stream_vtbl =
2442 stream_QueryInterface,
2443 stream_AddRef,
2444 stream_Release,
2445 stream_Read,
2446 stream_Write,
2447 stream_Seek,
2448 stream_SetSize,
2449 stream_CopyTo,
2450 stream_Commit,
2451 stream_Revert,
2452 stream_LockRegion,
2453 stream_UnlockRegion,
2454 stream_Stat,
2455 stream_Clone
2458 static IStream test_stream = { &stream_vtbl };
2460 static void test_DetectOutboundCodePageInIStream(IMultiLanguage3 *ml)
2462 HRESULT hr;
2463 UINT nb_detected, detected[4];
2464 UINT preferred[] = {1250,1251,1252,65001};
2465 UINT preferred2[] = {1250,1251,1252};
2467 nb_detected = 0;
2468 memset(detected, 0, sizeof(detected));
2469 hr = IMultiLanguage3_DetectOutboundCodePageInIStream(ml,
2470 MLDETECTF_PRESERVE_ORDER, &test_stream, preferred,
2471 ARRAY_SIZE(preferred), detected, &nb_detected, NULL);
2472 ok(hr == E_INVALIDARG, "got %08lx\n", hr);
2474 nb_detected = 1;
2475 memset(detected, 0, sizeof(detected));
2476 hr = IMultiLanguage3_DetectOutboundCodePageInIStream(ml,
2477 MLDETECTF_PRESERVE_ORDER, &test_stream, preferred,
2478 ARRAY_SIZE(preferred), NULL, &nb_detected, NULL);
2479 ok(hr == E_INVALIDARG, "got %08lx\n", hr);
2481 nb_detected = 1;
2482 memset(detected, 0, sizeof(detected));
2483 hr = IMultiLanguage3_DetectOutboundCodePageInIStream(ml,
2484 MLDETECTF_PRESERVE_ORDER, &test_stream, preferred,
2485 ARRAY_SIZE(preferred), detected, &nb_detected, NULL);
2486 ok(hr == S_OK, "got %08lx\n", hr);
2487 ok(nb_detected == 1, "got %u\n", nb_detected);
2488 ok(detected[0] == 65001, "got %u\n", detected[0]);
2490 nb_detected = 2;
2491 memset(detected, 0, sizeof(detected));
2492 hr = IMultiLanguage3_DetectOutboundCodePageInIStream(ml,
2493 MLDETECTF_PRESERVE_ORDER, &test_stream, preferred,
2494 ARRAY_SIZE(preferred), detected, &nb_detected, NULL);
2495 ok(hr == S_OK, "got %08lx\n", hr);
2496 todo_wine ok(nb_detected == 2, "got %u\n", nb_detected);
2497 ok(detected[0] == 65001, "got %u\n", detected[0]);
2498 todo_wine ok(detected[1] == 65000, "got %u\n", detected[1]);
2500 nb_detected = 3;
2501 memset(detected, 0, sizeof(detected));
2502 hr = IMultiLanguage3_DetectOutboundCodePageInIStream(ml,
2503 MLDETECTF_PRESERVE_ORDER, &test_stream, preferred,
2504 ARRAY_SIZE(preferred), detected, &nb_detected, NULL);
2505 ok(hr == S_OK, "got %08lx\n", hr);
2506 todo_wine ok(nb_detected == 3, "got %u\n", nb_detected);
2507 ok(detected[0] == 65001, "got %u\n", detected[0]);
2508 todo_wine ok(detected[1] == 65000, "got %u\n", detected[1]);
2509 todo_wine ok(detected[2] == 1200, "got %u\n", detected[2]);
2511 nb_detected = 4;
2512 memset(detected, 0, sizeof(detected));
2513 hr = IMultiLanguage3_DetectOutboundCodePageInIStream(ml,
2514 MLDETECTF_PRESERVE_ORDER, &test_stream, preferred,
2515 ARRAY_SIZE(preferred), detected, &nb_detected, NULL);
2516 ok(hr == S_OK, "got %08lx\n", hr);
2517 todo_wine ok(nb_detected == 3, "got %u\n", nb_detected);
2518 ok(detected[0] == 65001, "got %u\n", detected[0]);
2519 todo_wine ok(detected[1] == 65000, "got %u\n", detected[1]);
2520 todo_wine ok(detected[2] == 1200, "got %u\n", detected[2]);
2521 ok(detected[3] == 0, "got %u\n", detected[3]);
2523 nb_detected = 3;
2524 memset(detected, 0, sizeof(detected));
2525 hr = IMultiLanguage3_DetectOutboundCodePageInIStream(ml,
2526 MLDETECTF_PRESERVE_ORDER, &test_stream, preferred2,
2527 ARRAY_SIZE(preferred2), detected, &nb_detected, NULL);
2528 ok(hr == S_OK, "got %08lx\n", hr);
2529 todo_wine ok(nb_detected == 3, "got %u\n", nb_detected);
2530 ok(detected[0] == 65001, "got %u\n", detected[0]);
2531 todo_wine ok(detected[1] == 65000, "got %u\n", detected[1]);
2532 todo_wine ok(detected[2] == 1200, "got %u\n", detected[2]);
2535 /* Returns true if the user interface is in English. Note that this does not
2536 * presume of the formatting of dates, numbers, etc.
2538 static BOOL is_lang_english(void)
2540 static HMODULE hkernel32 = NULL;
2541 static LANGID (WINAPI *pGetThreadUILanguage)(void) = NULL;
2542 static LANGID (WINAPI *pGetUserDefaultUILanguage)(void) = NULL;
2544 if (!hkernel32)
2546 hkernel32 = GetModuleHandleA("kernel32.dll");
2547 pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
2548 pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
2550 if (pGetThreadUILanguage)
2551 return PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH;
2552 if (pGetUserDefaultUILanguage)
2553 return PRIMARYLANGID(pGetUserDefaultUILanguage()) == LANG_ENGLISH;
2555 return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
2558 static void test_GetCodePageInfo(IMultiLanguage2 *iML2)
2560 static const DWORD VALID_MASK = (DWORD)(~(MIMECONTF_VALID_NLS | MIMECONTF_VALID));
2562 const struct cpinfo_test_data *test_data = NULL;
2563 UINT test_data_num;
2564 MIMECPINFO cpinfo_cmp;
2565 MIMECPINFO cpinfo;
2566 UINT i;
2567 HRESULT ret;
2569 test_data = iml2_cpinfo_data;
2570 test_data_num = ARRAY_SIZE(iml2_cpinfo_data);
2571 for (i = 0; i < test_data_num; i++)
2573 ret = IMultiLanguage2_GetCodePageInfo(iML2, test_data[i].cpinfo.uiCodePage, LANG_NEUTRAL, &cpinfo);
2574 todo_wine_if(test_data[i].todo_GetCodePageInfo)
2575 ok(ret == S_OK, "%d: IMultiLanguage2_GetCodePageInfo failed: 0x%08lx.\n", i, ret);
2577 if (ret == S_OK)
2579 cpinfo_cmp = test_data[i].cpinfo;
2580 todo_wine_if(test_data[i].todo_dwFlags)
2581 ok((cpinfo.dwFlags == cpinfo_cmp.dwFlags ) ||
2582 /* some code pages are not installed on the Wine Test Bot */
2583 ((cpinfo.dwFlags & VALID_MASK) == (cpinfo_cmp.dwFlags & VALID_MASK)),
2584 "%d: got wrong dwFlags expected 0x%lx return 0x%lx.\n",
2585 i, cpinfo_cmp.dwFlags, cpinfo.dwFlags);
2586 ok(cpinfo.uiCodePage == cpinfo_cmp.uiCodePage,
2587 "%d: got wrong uiCodePage expected %u return %u.\n",
2588 i, cpinfo_cmp.uiCodePage, cpinfo.uiCodePage);
2589 todo_wine_if(test_data[i].todo_uiFamilyCodePage)
2590 ok(cpinfo.uiFamilyCodePage == cpinfo_cmp.uiFamilyCodePage,
2591 "%d: got wrong uiFamilyCodePage expected %u return %u.\n",
2592 i, cpinfo_cmp.uiFamilyCodePage, cpinfo.uiFamilyCodePage);
2594 todo_wine_if(test_data[i].todo_wszWebCharset)
2595 ok(!lstrcmpW(cpinfo.wszWebCharset, cpinfo_cmp.wszWebCharset),
2596 "%d: got wrong wszWebCharset expected %s return %s.\n",
2597 i, wine_dbgstr_w(cpinfo_cmp.wszWebCharset), wine_dbgstr_w(cpinfo.wszWebCharset));
2598 todo_wine_if(test_data[i].todo_wszHeaderCharset)
2599 ok(!lstrcmpW(cpinfo.wszHeaderCharset, cpinfo_cmp.wszHeaderCharset),
2600 "%d: got wrong wszHeaderCharset expected %s return %s.\n",
2601 i, wine_dbgstr_w(cpinfo_cmp.wszHeaderCharset), wine_dbgstr_w(cpinfo.wszHeaderCharset));
2602 todo_wine_if(test_data[i].todo_wszBodyCharset)
2603 ok(!lstrcmpW(cpinfo.wszBodyCharset, cpinfo_cmp.wszBodyCharset),
2604 "%d: got wrong wszBodyCharset expected %s return %s.\n",
2605 i, wine_dbgstr_w(cpinfo_cmp.wszBodyCharset), wine_dbgstr_w(cpinfo.wszBodyCharset));
2607 if (!is_lang_english())
2609 /* FIXME: Cannot test non-English descriptions and font names */
2610 skip("Non-English locale\n");
2612 else
2614 todo_wine_if(test_data[i].todo_wszDescription)
2615 ok(!lstrcmpW(cpinfo.wszDescription, cpinfo_cmp.wszDescription),
2616 "%d: got wrong wszDescription expected %s return %s.\n",
2617 i, wine_dbgstr_w(cpinfo_cmp.wszDescription), wine_dbgstr_w(cpinfo.wszDescription));
2618 todo_wine_if(test_data[i].todo_wszFixedWidthFont)
2619 ok(!lstrcmpW(cpinfo.wszFixedWidthFont, cpinfo_cmp.wszFixedWidthFont),
2620 "%d: got wrong wszFixedWidthFont expected %s return %s.\n",
2621 i, wine_dbgstr_w(cpinfo_cmp.wszFixedWidthFont), wine_dbgstr_w(cpinfo.wszFixedWidthFont));
2622 todo_wine_if(test_data[i].todo_wszProportionalFont)
2623 ok(!lstrcmpW(cpinfo.wszProportionalFont, cpinfo_cmp.wszProportionalFont),
2624 "%d: got wrong wszProportionalFont expected %s return %s.\n",
2625 i, wine_dbgstr_w(cpinfo_cmp.wszProportionalFont), wine_dbgstr_w(cpinfo.wszProportionalFont));
2631 static void test_MapFont(IMLangFontLink *font_link, IMLangFontLink2 *font_link2)
2633 HFONT old_font = NULL;
2634 HFONT new_font = NULL;
2635 HFONT last_font = NULL;
2636 HFONT font1 = NULL;
2637 HFONT font2 = NULL;
2638 DWORD codepages;
2639 DWORD font_codepages;
2640 HRESULT ret;
2641 HDC hdc;
2642 WCHAR ch;
2644 hdc = GetDC(NULL);
2645 codepages = FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC | FS_GREEK | FS_TURKISH |
2646 FS_HEBREW | FS_ARABIC | FS_BALTIC | FS_VIETNAMESE | FS_THAI |
2647 FS_JISJAPAN | FS_CHINESESIMP | FS_WANSUNG | FS_CHINESETRAD;
2648 old_font = GetCurrentObject(hdc, OBJ_FONT);
2649 ch = 0xfeed;
2651 /* Tests for IMLangFontLink */
2653 ret = IMLangFontLink_ResetFontMapping(font_link);
2654 ok(ret == S_OK, "IMLangFontLink_ResetFontMapping: expected S_OK, got %08lx\n", ret);
2656 ret = IMLangFontLink_MapFont(font_link, NULL, 0, NULL, NULL);
2657 ok(ret == E_FAIL, "IMLangFontLink_MapFont: expected E_FAIL, got %08lx\n", ret);
2658 ret = IMLangFontLink_MapFont(font_link, NULL, codepages, old_font, &new_font);
2659 ok(ret == E_FAIL, "IMLangFontLink_MapFont: expected E_FAIL, got %08lx\n", ret);
2660 ret = IMLangFontLink_MapFont(font_link, hdc, codepages, NULL, &new_font);
2661 ok(ret == E_FAIL, "IMLangFontLink_MapFont: expected E_FAIL, got %08lx\n", ret);
2663 ret = IMLangFontLink_MapFont(font_link, hdc, codepages, old_font, NULL);
2664 ok(ret == S_OK, "IMLangFontLink_MapFont: expected S_OK, got %08lx\n", ret);
2665 ret = IMLangFontLink_MapFont(font_link, hdc, codepages, old_font, &new_font);
2666 ok(ret == S_OK && new_font != NULL, "IMLangFontLink_MapFont: expected S_OK/!NULL, got %08lx/%p\n", ret, new_font);
2667 last_font = new_font;
2668 ret = IMLangFontLink_MapFont(font_link, hdc, codepages, old_font, &new_font);
2669 ok(ret == S_OK && new_font == last_font, "IMLangFontLink_MapFont: expected S_OK/%p, got %08lx/%p\n", last_font, ret, new_font);
2671 ret = IMLangFontLink_ReleaseFont(font_link, NULL);
2672 ok(ret == E_FAIL, "IMLangFontLink_ReleaseFont: expected E_FAIL, got %08lx\n", ret);
2673 ret = IMLangFontLink_ReleaseFont(font_link, new_font);
2674 ok(ret == S_OK, "IMLangFontLink_ReleaseFont: expected S_OK, got %08lx\n", ret);
2675 ret = IMLangFontLink_ResetFontMapping(font_link);
2676 ok(ret == S_OK, "IMLangFontLink_ResetFontMapping: expected S_OK, got %08lx\n", ret);
2678 /* Tests for IMLangFontLink2 */
2680 ret = IMLangFontLink2_ResetFontMapping(font_link2);
2681 ok(ret == S_OK, "IMLangFontLink2_ResetFontMapping: expected S_OK, got %08lx\n", ret);
2683 ret = IMLangFontLink2_MapFont(font_link2, NULL, 0, 0, NULL);
2684 ok(ret == E_FAIL, "IMLangFontLink2_MapFont: expected E_FAIL, got %08lx\n", ret);
2685 ret = IMLangFontLink2_MapFont(font_link2, NULL, codepages, ch, &new_font);
2686 ok(ret == E_FAIL, "IMLangFontLink2_MapFont: expected E_FAIL, got %08lx\n", ret);
2687 ret = IMLangFontLink2_MapFont(font_link2, hdc, 0, 0, NULL);
2688 ok(ret == E_INVALIDARG, "IMLangFontLink2_MapFont: expected E_INVALIDARG, got %08lx\n", ret);
2689 ret = IMLangFontLink2_MapFont(font_link2, hdc, 0, ch, NULL);
2690 ok(ret == E_INVALIDARG, "IMLangFontLink2_MapFont: expected E_INVALIDARG, got %08lx\n", ret);
2692 ret = IMLangFontLink2_MapFont(font_link2, hdc, 0, ch, &new_font);
2693 todo_wine
2694 ok(ret == S_OK || broken(ret == E_FAIL), /* got E_FAIL on winxp and win2k */
2695 "IMLangFontLink2_MapFont: expected S_OK || E_FAIL, got %08lx\n", ret);
2696 ret = IMLangFontLink2_MapFont(font_link2, hdc, codepages, 0, NULL);
2697 ok(ret == S_OK, "IMLangFontLink2_MapFont: expected S_OK, got %08lx\n", ret);
2698 ret = IMLangFontLink2_MapFont(font_link2, hdc, codepages, 0, &new_font);
2699 ok(ret == S_OK && new_font != NULL, "IMLangFontLink2_MapFont: expected S_OK/!NULL, got %08lx/%p\n", ret, new_font);
2700 last_font = new_font;
2701 ret = IMLangFontLink2_MapFont(font_link2, hdc, codepages, 0, &new_font);
2702 ok(ret == S_OK && new_font == last_font, "IMLangFontLink2_MapFont: expected S_OK/%p, got %08lx/%p\n", last_font, ret, new_font);
2704 ret = IMLangFontLink2_ReleaseFont(font_link2, NULL);
2705 ok(ret == E_FAIL, "IMLangFontLink2_ReleaseFont: expected E_FAIL, got %08lx\n", ret);
2706 ret = IMLangFontLink2_ReleaseFont(font_link2, new_font);
2707 ok(ret == S_OK, "IMLangFontLink2_ReleaseFont: expected S_OK, got %08lx\n", ret);
2708 ret = IMLangFontLink2_ResetFontMapping(font_link2);
2709 ok(ret == S_OK, "IMLangFontLink2_ResetFontMapping: expected S_OK, got %08lx\n", ret);
2711 /* Show that the font cache is global */
2712 ret = IMLangFontLink_MapFont(font_link, hdc, codepages, old_font, &font1);
2713 ok(ret == S_OK, "MapFont() failed, hr %#lx.\n", ret);
2714 ret = IMLangFontLink2_MapFont(font_link2, hdc, codepages, 0, &font2);
2715 ok(ret == S_OK, "MapFont() failed, hr %#lx.\n", ret);
2716 ok(font1 != NULL && font2 != NULL, "expected !NULL/!NULL, got %p/%p\n", font1, font2);
2717 ok(font1 == font2, "expected equal, got not equal\n");
2719 IMLangFontLink_GetFontCodePages(font_link, hdc, font1, &font_codepages);
2720 ok((codepages & (~font_codepages)) != 0 && (codepages & font_codepages) != 0,
2721 "code pages of font is incorrect\n");
2723 IMLangFontLink_ResetFontMapping(font_link);
2724 IMLangFontLink2_ResetFontMapping(font_link2);
2725 ReleaseDC(NULL, hdc);
2728 START_TEST(mlang)
2730 IMultiLanguage *iML = NULL;
2731 IMultiLanguage2 *iML2 = NULL;
2732 IMultiLanguage3 *iML3 = NULL;
2733 IMLangFontLink *iMLFL = NULL;
2734 IMLangFontLink2 *iMLFL2 = NULL;
2735 HRESULT ret;
2737 if (!init_function_ptrs())
2738 return;
2740 CoInitialize(NULL);
2741 test_Rfc1766ToLcid();
2742 test_LcidToRfc1766();
2744 test_ConvertINetUnicodeToMultiByte();
2745 test_JapaneseConversion();
2747 test_GetGlobalFontLinkObject();
2749 trace("IMultiLanguage\n");
2750 ret = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
2751 &IID_IMultiLanguage, (void **)&iML);
2752 if (ret != S_OK || !iML) return;
2754 test_GetNumberOfCodePageInfo((IMultiLanguage2 *)iML);
2755 test_IMLangConvertCharset(iML);
2756 test_GetCharsetInfo_other(iML);
2757 IMultiLanguage_Release(iML);
2760 /* IMultiLanguage2 (IE5.0 and above) */
2761 trace("IMultiLanguage2\n");
2762 ret = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
2763 &IID_IMultiLanguage2, (void **)&iML2);
2764 if (ret != S_OK || !iML2) return;
2766 test_rfc1766(iML2);
2767 test_GetLcidFromRfc1766(iML2);
2768 test_GetRfc1766FromLcid(iML2);
2769 test_GetRfc1766Info(iML2);
2770 test_GetNumberOfCodePageInfo(iML2);
2771 test_GetCodePageInfo(iML2);
2773 test_EnumCodePages(iML2, 0);
2774 test_EnumCodePages(iML2, MIMECONTF_MIME_LATEST);
2775 test_EnumCodePages(iML2, MIMECONTF_BROWSER);
2776 test_EnumCodePages(iML2, MIMECONTF_MINIMAL);
2777 test_EnumCodePages(iML2, MIMECONTF_VALID);
2778 /* FIXME: why MIMECONTF_MIME_REGISTRY returns 0 of supported codepages? */
2779 /*test_EnumCodePages(iML2, MIMECONTF_MIME_REGISTRY);*/
2781 test_EnumScripts(iML2, 0);
2782 test_EnumScripts(iML2, SCRIPTCONTF_SCRIPT_USER);
2783 test_EnumScripts(iML2, SCRIPTCONTF_SCRIPT_USER | SCRIPTCONTF_SCRIPT_HIDE | SCRIPTCONTF_SCRIPT_SYSTEM);
2785 ret = IMultiLanguage2_IsConvertible(iML2, CP_UTF8, CP_UNICODE);
2786 ok(ret == S_OK, "IMultiLanguage2_IsConvertible(CP_UTF8 -> CP_UNICODE) = %08lx\n", ret);
2787 ret = IMultiLanguage2_IsConvertible(iML2, CP_UNICODE, CP_UTF8);
2788 ok(ret == S_OK, "IMultiLanguage2_IsConvertible(CP_UNICODE -> CP_UTF8) = %08lx\n", ret);
2790 test_multibyte_to_unicode_translations(iML2);
2791 test_IMultiLanguage2_ConvertStringFromUnicode(iML2);
2793 test_IsCodePageInstallable(iML2);
2795 IMultiLanguage2_Release(iML2);
2798 /* IMLangFontLink */
2799 ret = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
2800 &IID_IMLangFontLink, (void **)&iMLFL);
2801 if (ret != S_OK || !iMLFL) return;
2803 IMLangFontLink_Test(iMLFL);
2805 /* IMLangFontLink2 */
2806 ret = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
2807 &IID_IMLangFontLink2, (void **)&iMLFL2);
2808 if (ret != S_OK || !iMLFL2) return;
2810 test_GetScriptFontInfo(iMLFL2);
2811 test_GetFontUnicodeRanges(iMLFL2);
2812 test_CodePageToScriptID(iMLFL2);
2813 test_MapFont(iMLFL, iMLFL2);
2815 IMLangFontLink_Release(iMLFL);
2816 IMLangFontLink2_Release(iMLFL2);
2818 trace("IMultiLanguage3\n");
2819 ret = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
2820 &IID_IMultiLanguage3, (void **)&iML3);
2821 if (ret == S_OK)
2823 test_DetectOutboundCodePageInIStream(iML3);
2824 IMultiLanguage3_Release(iML3);
2827 CoUninitialize();