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
33 #include "wine/test.h"
36 #define CP_UNICODE 1200
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
,
47 static HRESULT (WINAPI
*pRfc1766ToLcidA
)(LCID
*, LPCSTR
);
48 static HRESULT (WINAPI
*pLcidToRfc1766A
)(LCID
, LPSTR
, INT
);
50 typedef struct lcid_tag_table
{
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
[] = {
72 {"de-ch", 0x0807, S_OK
},
73 {"de-at", 0x0c07, S_OK
},
74 {"de-lu", 0x1007, S_OK
},
75 {"de-li", 0x1407, 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
},
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"},
92 {"it-ch", 0x0810, S_OK
},
95 {"nl-be", 0x0813, S_OK
},
99 {"kok", 0x0457, S_OK
, 0x0412, "x-kok"}
105 typedef struct info_table_tag
{
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_de
[] = {'D','e','u','t','s','c','h',' ',
125 '(','D','e','u','t','s','c','h','l','a','n','d',')',0};
126 static const WCHAR de_deat
[] = {'D','e','u','t','s','c','h',' ',
127 '(',0xD6,'s','t','e','r','r','e','i','c','h',')',0};
128 static const WCHAR de_dech
[] = {'D','e','u','t','s','c','h',' ',
129 '(','S','c','h','w','e','i','z',')',0};
131 static const WCHAR en_en
[] = {'E','n','g','l','i','s','h',0};
132 static const WCHAR en_enca
[] = {'E','n','g','l','i','s','h',' ',
133 '(','C','a','n','a','d','a',')',0};
134 static const WCHAR en_engb
[] = {'E','n','g','l','i','s','h',' ',
135 '(','U','n','i','t','e','d',' ','K','i','n','g','d','o','m',')',0};
136 static const WCHAR en_enus
[] = {'E','n','g','l','i','s','h',' ',
137 '(','U','n','i','t','e','d',' ','S','t','a','t','e','s',')',0};
138 static const WCHAR en_de
[] = {'G','e','r','m','a','n',' ',
139 '(','G','e','r','m','a','n','y',')',0};
140 static const WCHAR en_deat
[] = {'G','e','r','m','a','n',' ',
141 '(','A','u','s','t','r','i','a',')',0};
142 static const WCHAR en_dech
[] = {'G','e','r','m','a','n',' ',
143 '(','S','w','i','t','z','e','r','l','a','n','d',')',0};
145 static const WCHAR fr_en
[] = {'A','n','g','l','a','i','s',0};
146 static const WCHAR fr_enca
[] = {'A','n','g','l','a','i','s',' ',
147 '(','C','a','n','a','d','a',')',0};
148 static const WCHAR fr_engb
[] = {'A','n','g','l','a','i','s',' ',
149 '(','R','o','y','a','u','m','e','-','U','n','i',')',0};
150 static const WCHAR fr_enus
[] = {'A','n','g','l','a','i','s',' ',
151 '(',0xC9, 't','a','t','s','-','U','n','i','s',')',0};
152 static const WCHAR fr_enus2
[] ={'A','n','g','l','a','i','s',' ',
153 '(','U','.','S','.',')',0};
154 static const WCHAR fr_de
[] = {'A','l','l','e','m','a','n','d',' ',
155 '(','A','l','l','e','m','a','g','n','e',')',0};
156 static const WCHAR fr_de2
[] = {'A','l','l','e','m','a','n','d',' ',
157 '(','S','t','a','n','d','a','r','d',')',0};
158 static const WCHAR fr_deat
[] = {'A','l','l','e','m','a','n','d',' ',
159 '(','A','u','t','r','i','c','h','e',')',0};
160 static const WCHAR fr_dech
[] = {'A','l','l','e','m','a','n','d',' ',
161 '(','S','u','i','s','s','e',')',0};
163 static const info_table_entry info_table
[] = {
164 {MAKELANGID(LANG_ENGLISH
, SUBLANG_NEUTRAL
), MAKELANGID(LANG_ENGLISH
, SUBLANG_NEUTRAL
),
166 {MAKELANGID(LANG_ENGLISH
, SUBLANG_DEFAULT
), MAKELANGID(LANG_ENGLISH
, SUBLANG_NEUTRAL
),
167 0, "en-us", en_enus
},
168 {MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_UK
), MAKELANGID(LANG_ENGLISH
, SUBLANG_NEUTRAL
),
169 0, "en-gb", en_engb
},
170 {MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), MAKELANGID(LANG_ENGLISH
, SUBLANG_NEUTRAL
),
171 0, "en-us", en_enus
},
172 {MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_CAN
), MAKELANGID(LANG_ENGLISH
, SUBLANG_NEUTRAL
),
173 0, "en-ca", en_enca
},
175 {MAKELANGID(LANG_GERMAN
, SUBLANG_DEFAULT
), MAKELANGID(LANG_ENGLISH
, SUBLANG_NEUTRAL
),
177 {MAKELANGID(LANG_GERMAN
, SUBLANG_GERMAN
), MAKELANGID(LANG_ENGLISH
, SUBLANG_NEUTRAL
),
179 {MAKELANGID(LANG_GERMAN
, SUBLANG_GERMAN_SWISS
), MAKELANGID(LANG_ENGLISH
, SUBLANG_NEUTRAL
),
180 0, "de-ch", en_dech
},
181 {MAKELANGID(LANG_GERMAN
, SUBLANG_GERMAN_AUSTRIAN
), MAKELANGID(LANG_ENGLISH
, SUBLANG_NEUTRAL
),
182 0, "de-at", en_deat
},
184 {MAKELANGID(LANG_ENGLISH
, SUBLANG_NEUTRAL
), MAKELANGID(LANG_GERMAN
, SUBLANG_DEFAULT
),
185 TODO_NAME
, "en", de_en
},
186 {MAKELANGID(LANG_ENGLISH
, SUBLANG_DEFAULT
), MAKELANGID(LANG_GERMAN
, SUBLANG_DEFAULT
),
187 TODO_NAME
, "en-us", de_enus
},
188 {MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_UK
), MAKELANGID(LANG_GERMAN
, SUBLANG_DEFAULT
),
189 TODO_NAME
, "en-gb", de_engb
, de_engb2
},
190 {MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), MAKELANGID(LANG_GERMAN
, SUBLANG_DEFAULT
),
191 TODO_NAME
, "en-us", de_enus
},
192 {MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_CAN
), MAKELANGID(LANG_GERMAN
, SUBLANG_DEFAULT
),
193 TODO_NAME
, "en-ca", de_enca
},
195 {MAKELANGID(LANG_GERMAN
, SUBLANG_DEFAULT
), MAKELANGID(LANG_GERMAN
, SUBLANG_DEFAULT
),
196 TODO_NAME
, "de", de_de
},
197 {MAKELANGID(LANG_GERMAN
, SUBLANG_GERMAN
), MAKELANGID(LANG_GERMAN
, SUBLANG_DEFAULT
),
198 TODO_NAME
, "de",de_de
},
199 {MAKELANGID(LANG_GERMAN
, SUBLANG_GERMAN_SWISS
), MAKELANGID(LANG_GERMAN
, SUBLANG_DEFAULT
),
200 TODO_NAME
, "de-ch", de_dech
},
201 {MAKELANGID(LANG_GERMAN
, SUBLANG_GERMAN_AUSTRIAN
), MAKELANGID(LANG_GERMAN
, SUBLANG_DEFAULT
),
202 TODO_NAME
, "de-at", de_deat
},
204 {MAKELANGID(LANG_ENGLISH
, SUBLANG_NEUTRAL
), MAKELANGID(LANG_FRENCH
, SUBLANG_DEFAULT
),
205 TODO_NAME
, "en", fr_en
},
206 {MAKELANGID(LANG_ENGLISH
, SUBLANG_DEFAULT
), MAKELANGID(LANG_FRENCH
, SUBLANG_DEFAULT
),
207 TODO_NAME
, "en-us", fr_enus
, fr_enus2
},
208 {MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_UK
), MAKELANGID(LANG_FRENCH
, SUBLANG_DEFAULT
),
209 TODO_NAME
, "en-gb", fr_engb
},
210 {MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), MAKELANGID(LANG_FRENCH
, SUBLANG_DEFAULT
),
211 TODO_NAME
, "en-us", fr_enus
, fr_enus2
},
212 {MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_CAN
), MAKELANGID(LANG_FRENCH
, SUBLANG_DEFAULT
),
213 TODO_NAME
, "en-ca", fr_enca
},
215 {MAKELANGID(LANG_GERMAN
, SUBLANG_DEFAULT
), MAKELANGID(LANG_FRENCH
, SUBLANG_DEFAULT
),
216 TODO_NAME
, "de", fr_de
, fr_de2
},
217 {MAKELANGID(LANG_GERMAN
, SUBLANG_GERMAN
), MAKELANGID(LANG_FRENCH
, SUBLANG_DEFAULT
),
218 TODO_NAME
, "de", fr_de
, fr_de2
},
219 {MAKELANGID(LANG_GERMAN
, SUBLANG_GERMAN_SWISS
), MAKELANGID(LANG_FRENCH
, SUBLANG_DEFAULT
),
220 TODO_NAME
, "de-ch", fr_dech
},
221 {MAKELANGID(LANG_GERMAN
, SUBLANG_GERMAN_AUSTRIAN
), MAKELANGID(LANG_FRENCH
, SUBLANG_DEFAULT
),
222 TODO_NAME
, "de-at", fr_deat
}
226 static BOOL
init_function_ptrs(void)
230 hMlang
= LoadLibraryA("mlang.dll");
233 skip("mlang not available\n");
237 pConvertINetMultiByteToUnicode
= (void *)GetProcAddress(hMlang
, "ConvertINetMultiByteToUnicode");
238 pConvertINetUnicodeToMultiByte
= (void *)GetProcAddress(hMlang
, "ConvertINetUnicodeToMultiByte");
239 pRfc1766ToLcidA
= (void *)GetProcAddress(hMlang
, "Rfc1766ToLcidA");
240 pLcidToRfc1766A
= (void *)GetProcAddress(hMlang
, "LcidToRfc1766A");
242 pGetCPInfoExA
= (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetCPInfoExA");
247 #define ok_w2(format, szString1, szString2) \
249 if (lstrcmpW((szString1), (szString2)) != 0) \
251 CHAR string1[256], string2[256]; \
252 WideCharToMultiByte(CP_ACP, 0, (szString1), -1, string1, 256, NULL, NULL); \
253 WideCharToMultiByte(CP_ACP, 0, (szString2), -1, string2, 256, NULL, NULL); \
254 ok(0, (format), string1, string2); \
257 static void test_multibyte_to_unicode_translations(IMultiLanguage2
*iML2
)
259 /* these APIs are broken regarding constness of the input buffer */
260 char stringA
[] = "Just a test string\0"; /* double 0 for CP_UNICODE tests */
261 WCHAR stringW
[] = {'J','u','s','t',' ','a',' ','t','e','s','t',' ','s','t','r','i','n','g',0};
264 UINT lenA
, lenW
, expected_len
;
267 /* IMultiLanguage2_ConvertStringToUnicode tests */
269 memset(bufW
, 'x', sizeof(bufW
));
271 lenW
= sizeof(bufW
)/sizeof(bufW
[0]);
272 ret
= IMultiLanguage2_ConvertStringToUnicode(iML2
, NULL
, 1252, stringA
, &lenA
, bufW
, &lenW
);
273 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringToUnicode failed: %08x\n", ret
);
274 ok(lenA
== 0, "expected lenA 0, got %u\n", lenA
);
275 ok(lenW
== 0, "expected lenW 0, got %u\n", lenW
);
277 memset(bufW
, 'x', sizeof(bufW
));
279 lenW
= sizeof(bufW
)/sizeof(bufW
[0]);
280 ret
= IMultiLanguage2_ConvertStringToUnicode(iML2
, NULL
, 1252, stringA
, &lenA
, bufW
, &lenW
);
281 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringToUnicode failed: %08x\n", ret
);
282 ok(lenA
== lstrlenA(stringA
), "expected lenA %u, got %u\n", lstrlenA(stringA
), lenA
);
283 ok(lenW
== lstrlenW(stringW
), "expected lenW %u, got %u\n", lstrlenW(stringW
), lenW
);
284 if (lenW
< sizeof(bufW
)/sizeof(bufW
[0])) {
285 /* can only happen if the convert call fails */
286 ok(bufW
[lenW
] != 0, "buf should not be 0 terminated\n");
287 bufW
[lenW
] = 0; /* -1 doesn't include 0 terminator */
289 ok(!lstrcmpW(bufW
, stringW
), "bufW/stringW mismatch\n");
291 memset(bufW
, 'x', sizeof(bufW
));
294 ret
= IMultiLanguage2_ConvertStringToUnicode(iML2
, NULL
, 1252, stringA
, &lenA
, bufW
, &lenW
);
295 ok(ret
== E_FAIL
, "IMultiLanguage2_ConvertStringToUnicode should fail: %08x\n", ret
);
296 ok(lenW
== 0, "expected lenW 0, got %u\n", lenW
);
297 /* still has to do partial conversion */
298 ok(!memcmp(bufW
, stringW
, 5 * sizeof(WCHAR
)), "bufW/stringW mismatch\n");
300 memset(bufW
, 'x', sizeof(bufW
));
302 lenW
= sizeof(bufW
)/sizeof(bufW
[0]);
303 ret
= IMultiLanguage2_ConvertStringToUnicode(iML2
, NULL
, CP_UNICODE
, stringA
, &lenA
, bufW
, &lenW
);
304 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringToUnicode failed: %08x\n", ret
);
305 ok(lenA
== lstrlenA(stringA
), "expected lenA %u, got %u\n", lstrlenA(stringA
), lenA
);
306 ok(lenW
== lstrlenW(stringW
)/(int)sizeof(WCHAR
), "wrong lenW %u\n", lenW
);
307 ok(bufW
[lenW
] != 0, "buf should not be 0 terminated\n");
308 bufW
[lenW
] = 0; /* -1 doesn't include 0 terminator */
309 ok(!lstrcmpA((LPCSTR
)bufW
, stringA
), "bufW/stringA mismatch\n");
311 memset(bufW
, 'x', sizeof(bufW
));
312 lenA
= lstrlenA(stringA
);
314 ret
= IMultiLanguage2_ConvertStringToUnicode(iML2
, NULL
, 1252, stringA
, &lenA
, NULL
, &lenW
);
315 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringToUnicode failed: %08x\n", ret
);
316 ok(lenA
== lstrlenA(stringA
), "expected lenA %u, got %u\n", lstrlenA(stringA
), lenA
);
317 expected_len
= MultiByteToWideChar(1252, 0, stringA
, lenA
, NULL
, 0);
318 ok(lenW
== expected_len
, "expected lenW %u, got %u\n", expected_len
, lenW
);
320 memset(bufW
, 'x', sizeof(bufW
));
321 lenA
= lstrlenA(stringA
);
322 lenW
= sizeof(bufW
)/sizeof(bufW
[0]);
323 ret
= pConvertINetMultiByteToUnicode(NULL
, 1252, stringA
, (INT
*)&lenA
, NULL
, (INT
*)&lenW
);
324 ok(ret
== S_OK
, "ConvertINetMultiByteToUnicode failed: %08x\n", ret
);
325 ok(lenA
== lstrlenA(stringA
), "expected lenA %u, got %u\n", lstrlenA(stringA
), lenA
);
326 expected_len
= MultiByteToWideChar(1252, 0, stringA
, lenA
, NULL
, 0);
327 ok(lenW
== expected_len
, "expected lenW %u, got %u\n", expected_len
, lenW
);
329 memset(bufW
, 'x', sizeof(bufW
));
330 lenA
= lstrlenA(stringA
);
332 ret
= pConvertINetMultiByteToUnicode(NULL
, 1252, stringA
, (INT
*)&lenA
, NULL
, (INT
*)&lenW
);
333 ok(ret
== S_OK
, "ConvertINetMultiByteToUnicode failed: %08x\n", ret
);
334 ok(lenA
== lstrlenA(stringA
), "expected lenA %u, got %u\n", lstrlenA(stringA
), lenA
);
335 expected_len
= MultiByteToWideChar(1252, 0, stringA
, lenA
, NULL
, 0);
336 ok(lenW
== expected_len
, "expected lenW %u, got %u\n", expected_len
, lenW
);
338 /* IMultiLanguage2_ConvertStringFromUnicode tests */
340 memset(bufA
, 'x', sizeof(bufA
));
343 ret
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, stringW
, &lenW
, bufA
, &lenA
);
344 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringFromUnicode failed: %08x\n", ret
);
345 ok(lenA
== 0, "expected lenA 0, got %u\n", lenA
);
346 ok(lenW
== 0, "expected lenW 0, got %u\n", lenW
);
348 memset(bufA
, 'x', sizeof(bufA
));
351 ret
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, stringW
, &lenW
, bufA
, &lenA
);
352 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringFromUnicode failed: %08x\n", ret
);
353 ok(lenA
== lstrlenA(stringA
), "expected lenA %u, got %u\n", lstrlenA(stringA
), lenA
);
354 ok(lenW
== lstrlenW(stringW
), "expected lenW %u, got %u\n", lstrlenW(stringW
), lenW
);
355 ok(bufA
[lenA
] != 0, "buf should not be 0 terminated\n");
356 bufA
[lenA
] = 0; /* -1 doesn't include 0 terminator */
357 ok(!lstrcmpA(bufA
, stringA
), "bufA/stringA mismatch\n");
359 memset(bufA
, 'x', sizeof(bufA
));
362 ret
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, stringW
, &lenW
, bufA
, &lenA
);
363 ok(ret
== E_FAIL
, "IMultiLanguage2_ConvertStringFromUnicode should fail: %08x\n", ret
);
364 ok(lenA
== 0, "expected lenA 0, got %u\n", lenA
);
365 /* still has to do partial conversion */
366 ok(!memcmp(bufA
, stringA
, 5), "bufW/stringW mismatch\n");
368 memset(bufA
, 'x', sizeof(bufA
));
371 ret
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, CP_UNICODE
, stringW
, &lenW
, bufA
, &lenA
);
372 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringFromUnicode failed: %08x\n", ret
);
373 ok(lenA
== lstrlenA(stringA
) * (int)sizeof(WCHAR
), "wrong lenA %u\n", lenA
);
374 ok(lenW
== lstrlenW(stringW
), "expected lenW %u, got %u\n", lstrlenW(stringW
), lenW
);
375 ok(bufA
[lenA
] != 0 && bufA
[lenA
+1] != 0, "buf should not be 0 terminated\n");
376 bufA
[lenA
] = 0; /* -1 doesn't include 0 terminator */
377 bufA
[lenA
+1] = 0; /* sizeof(WCHAR) */
378 ok(!lstrcmpW((LPCWSTR
)bufA
, stringW
), "bufA/stringW mismatch\n");
380 memset(bufA
, 'x', sizeof(bufA
));
381 lenW
= lstrlenW(stringW
);
383 ret
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, stringW
, &lenW
, NULL
, &lenA
);
384 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringFromUnicode failed: %08x\n", ret
);
385 ok(lenW
== lstrlenW(stringW
), "expected lenW %u, got %u\n", lstrlenW(stringW
), lenW
);
386 expected_len
= WideCharToMultiByte(1252, 0, stringW
, lenW
, NULL
, 0, NULL
, NULL
);
387 ok(lenA
== expected_len
, "expected lenA %u, got %u\n", expected_len
, lenA
);
390 static void cpinfo_cmp(MIMECPINFO
*cpinfo1
, MIMECPINFO
*cpinfo2
)
392 ok(cpinfo1
->dwFlags
== cpinfo2
->dwFlags
, "dwFlags mismatch: %08x != %08x\n", cpinfo1
->dwFlags
, cpinfo2
->dwFlags
);
393 ok(cpinfo1
->uiCodePage
== cpinfo2
->uiCodePage
, "uiCodePage mismatch: %u != %u\n", cpinfo1
->uiCodePage
, cpinfo2
->uiCodePage
);
394 ok(cpinfo1
->uiFamilyCodePage
== cpinfo2
->uiFamilyCodePage
, "uiFamilyCodePage mismatch: %u != %u\n", cpinfo1
->uiFamilyCodePage
, cpinfo2
->uiFamilyCodePage
);
395 ok(!lstrcmpW(cpinfo1
->wszDescription
, cpinfo2
->wszDescription
), "wszDescription mismatch\n");
396 ok(!lstrcmpW(cpinfo1
->wszWebCharset
, cpinfo2
->wszWebCharset
), "wszWebCharset mismatch\n");
397 ok(!lstrcmpW(cpinfo1
->wszHeaderCharset
, cpinfo2
->wszHeaderCharset
), "wszHeaderCharset mismatch\n");
398 ok(!lstrcmpW(cpinfo1
->wszBodyCharset
, cpinfo2
->wszBodyCharset
), "wszBodyCharset mismatch\n");
399 ok(!lstrcmpW(cpinfo1
->wszFixedWidthFont
, cpinfo2
->wszFixedWidthFont
), "wszFixedWidthFont mismatch\n");
400 ok(!lstrcmpW(cpinfo1
->wszProportionalFont
, cpinfo2
->wszProportionalFont
), "wszProportionalFont mismatch\n");
401 ok(cpinfo1
->bGDICharset
== cpinfo2
->bGDICharset
, "bGDICharset mismatch: %d != %d\n", cpinfo1
->bGDICharset
, cpinfo2
->bGDICharset
);
405 static const char *dump_mime_flags(DWORD flags
)
407 static char buf
[1024];
411 if (flags
& MIMECONTF_MAILNEWS
) strcat(buf
, " MIMECONTF_MAILNEWS");
412 if (flags
& MIMECONTF_BROWSER
) strcat(buf
, " MIMECONTF_BROWSER");
413 if (flags
& MIMECONTF_MINIMAL
) strcat(buf
, " MIMECONTF_MINIMAL");
414 if (flags
& MIMECONTF_IMPORT
) strcat(buf
, " MIMECONTF_IMPORT");
415 if (flags
& MIMECONTF_SAVABLE_MAILNEWS
) strcat(buf
, " MIMECONTF_SAVABLE_MAILNEWS");
416 if (flags
& MIMECONTF_SAVABLE_BROWSER
) strcat(buf
, " MIMECONTF_SAVABLE_BROWSER");
417 if (flags
& MIMECONTF_EXPORT
) strcat(buf
, " MIMECONTF_EXPORT");
418 if (flags
& MIMECONTF_PRIVCONVERTER
) strcat(buf
, " MIMECONTF_PRIVCONVERTER");
419 if (flags
& MIMECONTF_VALID
) strcat(buf
, " MIMECONTF_VALID");
420 if (flags
& MIMECONTF_VALID_NLS
) strcat(buf
, " MIMECONTF_VALID_NLS");
421 if (flags
& MIMECONTF_MIME_IE4
) strcat(buf
, " MIMECONTF_MIME_IE4");
422 if (flags
& MIMECONTF_MIME_LATEST
) strcat(buf
, " MIMECONTF_MIME_LATEST");
423 if (flags
& MIMECONTF_MIME_REGISTRY
) strcat(buf
, " MIMECONTF_MIME_REGISTRY");
429 static HRESULT
check_convertible(IMultiLanguage2
*iML2
, UINT from
, UINT to
)
431 CHAR convert
[MAX_PATH
];
436 static WCHAR strW
[] = {'a','b','c',0};
438 /* Check to see if the target codepage has these characters or not */
444 cb
= WideCharToMultiByte( from
, WC_NO_BEST_FIT_CHARS
| WC_COMPOSITECHECK
| WC_DEFAULTCHAR
,
445 strW
, 3, ch
, sizeof(ch
), NULL
, &fDefaultChar
);
447 if(cb
== 0 || fDefaultChar
)
449 trace("target codepage %i does not contain 'abc'\n",from
);
454 srcsz
= lstrlenW(strW
) + 1;
456 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, from
, strW
,
457 &srcsz
, convert
, &destsz
);
463 hr
= IMultiLanguage2_ConvertString(iML2
, NULL
, from
, to
, (BYTE
*)convert
,
464 &srcsz
, dest
, &destsz
);
471 static void test_EnumCodePages(IMultiLanguage2
*iML2
, DWORD flags
)
473 IEnumCodePage
*iEnumCP
= NULL
;
481 ret
= IMultiLanguage2_GetNumberOfCodePageInfo(iML2
, &total
);
482 ok(ret
== S_OK
&& total
!= 0, "IMultiLanguage2_GetNumberOfCodePageInfo: expected S_OK/!0, got %08x/%u\n", ret
, total
);
484 trace("total mlang supported codepages %u\n", total
);
486 ret
= IMultiLanguage2_EnumCodePages(iML2
, flags
, LANG_NEUTRAL
, &iEnumCP
);
487 ok(ret
== S_OK
&& iEnumCP
, "IMultiLanguage2_EnumCodePages: expected S_OK/!NULL, got %08x/%p\n", ret
, iEnumCP
);
489 ret
= IEnumCodePage_Reset(iEnumCP
);
490 ok(ret
== S_OK
, "IEnumCodePage_Reset: expected S_OK, got %08x\n", ret
);
492 ret
= IEnumCodePage_Next(iEnumCP
, 0, NULL
, &n
);
494 ok(n
== 0 && ret
== S_FALSE
, "IEnumCodePage_Next: expected 0/S_FALSE, got %u/%08x\n", n
, ret
);
495 else if (ret
== E_FAIL
)
496 ok(n
== 65536 && ret
== E_FAIL
, "IEnumCodePage_Next: expected 65536/E_FAIL, got %u/%08x\n", n
, ret
);
497 ret
= IEnumCodePage_Next(iEnumCP
, 0, NULL
, NULL
);
499 ok(ret
== S_FALSE
, "IEnumCodePage_Next: expected S_FALSE, got %08x\n", ret
);
500 else if (ret
== E_FAIL
)
501 ok(n
== 65536 && ret
== E_FAIL
, "IEnumCodePage_Next: expected 65536/E_FAIL, got %u/%08x\n", n
, ret
);
503 cpinfo
= HeapAlloc(GetProcessHeap(), 0, sizeof(*cpinfo
) * total
* 2);
506 ret
= IEnumCodePage_Next(iEnumCP
, 0, cpinfo
, &n
);
507 ok(ret
== S_FALSE
&& n
== 0, "IEnumCodePage_Next: expected S_FALSE/0, got %08x/%u\n", ret
, n
);
510 ret
= IEnumCodePage_Next(iEnumCP
, n
, cpinfo
, &n
);
511 ok(ret
== S_OK
&& n
!= 0, "IEnumCodePage_Next: expected S_OK/!0, got %08x/%u\n", ret
, n
);
513 trace("flags %08x, enumerated codepages %u\n", flags
, n
);
517 ok(n
== total
, "IEnumCodePage_Next: expected %u, got %u\n", total
, n
);
519 flags
= MIMECONTF_MIME_LATEST
;
524 for (i
= 0; i
< n
; i
++)
528 HRESULT convertible
= S_OK
;
529 static const WCHAR autoW
[] = {'_','a','u','t','o',0};
530 static const WCHAR feffW
[] = {'u','n','i','c','o','d','e','F','E','F','F',0};
533 trace("MIMECPINFO #%u:\n"
536 "uiFamilyCodePage %u\n"
537 "wszDescription %s\n"
539 "wszHeaderCharset %s\n"
540 "wszBodyCharset %s\n"
541 "wszFixedWidthFont %s\n"
542 "wszProportionalFont %s\n"
543 "bGDICharset %d\n\n",
545 cpinfo
[i
].dwFlags
, dump_mime_flags(cpinfo
[i
].dwFlags
),
546 cpinfo
[i
].uiCodePage
,
547 cpinfo
[i
].uiFamilyCodePage
,
548 wine_dbgstr_w(cpinfo
[i
].wszDescription
),
549 wine_dbgstr_w(cpinfo
[i
].wszWebCharset
),
550 wine_dbgstr_w(cpinfo
[i
].wszHeaderCharset
),
551 wine_dbgstr_w(cpinfo
[i
].wszBodyCharset
),
552 wine_dbgstr_w(cpinfo
[i
].wszFixedWidthFont
),
553 wine_dbgstr_w(cpinfo
[i
].wszProportionalFont
),
554 cpinfo
[i
].bGDICharset
);
556 ok(cpinfo
[i
].dwFlags
& flags
, "enumerated flags %08x do not include requested %08x\n", cpinfo
[i
].dwFlags
, flags
);
558 if (TranslateCharsetInfo((DWORD
*)(INT_PTR
)cpinfo
[i
].uiFamilyCodePage
, &csi
, TCI_SRCCODEPAGE
))
559 ok(cpinfo
[i
].bGDICharset
== csi
.ciCharset
, "%d != %d\n", cpinfo
[i
].bGDICharset
, csi
.ciCharset
);
561 if (winetest_debug
> 1)
562 trace("TranslateCharsetInfo failed for cp %u\n", cpinfo
[i
].uiFamilyCodePage
);
565 trace("%u: codepage %u family %u\n", i
, cpinfo
[i
].uiCodePage
, cpinfo
[i
].uiFamilyCodePage
);
568 /* support files for some codepages might be not installed, or
569 * the codepage is just an alias.
571 if (IsValidCodePage(cpinfo
[i
].uiCodePage
))
573 ret
= IMultiLanguage2_IsConvertible(iML2
, cpinfo
[i
].uiCodePage
, CP_UNICODE
);
574 ok(ret
== S_OK
, "IMultiLanguage2_IsConvertible(%u -> CP_UNICODE) = %08x\n", cpinfo
[i
].uiCodePage
, ret
);
575 ret
= IMultiLanguage2_IsConvertible(iML2
, CP_UNICODE
, cpinfo
[i
].uiCodePage
);
576 ok(ret
== S_OK
, "IMultiLanguage2_IsConvertible(CP_UNICODE -> %u) = %08x\n", cpinfo
[i
].uiCodePage
, ret
);
578 convertible
= check_convertible(iML2
, cpinfo
[i
].uiCodePage
, CP_UTF8
);
579 if (convertible
!= E_FAIL
)
581 ret
= IMultiLanguage2_IsConvertible(iML2
, cpinfo
[i
].uiCodePage
, CP_UTF8
);
582 ok(ret
== convertible
, "IMultiLanguage2_IsConvertible(%u -> CP_UTF8) = %08x\n", cpinfo
[i
].uiCodePage
, ret
);
583 ret
= IMultiLanguage2_IsConvertible(iML2
, CP_UTF8
, cpinfo
[i
].uiCodePage
);
584 ok(ret
== convertible
, "IMultiLanguage2_IsConvertible(CP_UTF8 -> %u) = %08x\n", cpinfo
[i
].uiCodePage
, ret
);
588 if (winetest_debug
> 1)
589 trace("IsValidCodePage failed for cp %u\n", cpinfo
[i
].uiCodePage
);
591 if (memcmp(cpinfo
[i
].wszWebCharset
,feffW
,sizeof(WCHAR
)*11)==0)
592 skip("Legacy windows bug returning invalid charset of unicodeFEFF\n");
595 ret
= IMultiLanguage2_GetCharsetInfo(iML2
, cpinfo
[i
].wszWebCharset
, &mcsi
);
596 /* _autoxxx charsets are a fake and GetCharsetInfo fails for them */
597 if (memcmp(cpinfo
[i
].wszWebCharset
, autoW
, 5 * sizeof(WCHAR
)))
599 ok (ret
== S_OK
, "IMultiLanguage2_GetCharsetInfo failed: %08x\n", ret
);
601 trace("%s: %u %u %s\n", wine_dbgstr_w(cpinfo
[i
].wszWebCharset
), mcsi
.uiCodePage
, mcsi
.uiInternetEncoding
, wine_dbgstr_w(mcsi
.wszCharset
));
603 ok(!lstrcmpiW(cpinfo
[i
].wszWebCharset
, mcsi
.wszCharset
), "%s != %s\n",
604 wine_dbgstr_w(cpinfo
[i
].wszWebCharset
), wine_dbgstr_w(mcsi
.wszCharset
));
608 /* native mlang returns completely messed up encodings in some cases */
609 ok(mcsi
.uiInternetEncoding
== cpinfo
[i
].uiCodePage
|| mcsi
.uiInternetEncoding
== cpinfo
[i
].uiFamilyCodePage
,
610 "%u != %u || %u\n", mcsi
.uiInternetEncoding
, cpinfo
[i
].uiCodePage
, cpinfo
[i
].uiFamilyCodePage
);
611 ok(mcsi
.uiCodePage
== cpinfo
[i
].uiCodePage
|| mcsi
.uiCodePage
== cpinfo
[i
].uiFamilyCodePage
,
612 "%u != %u || %u\n", mcsi
.uiCodePage
, cpinfo
[i
].uiCodePage
, cpinfo
[i
].uiFamilyCodePage
);
617 if (memcmp(cpinfo
[i
].wszHeaderCharset
,feffW
,sizeof(WCHAR
)*11)==0)
618 skip("Legacy windows bug returning invalid charset of unicodeFEFF\n");
621 ret
= IMultiLanguage2_GetCharsetInfo(iML2
, cpinfo
[i
].wszHeaderCharset
, &mcsi
);
622 /* _autoxxx charsets are a fake and GetCharsetInfo fails for them */
623 if (memcmp(cpinfo
[i
].wszHeaderCharset
, autoW
, 5 * sizeof(WCHAR
)))
625 ok (ret
== S_OK
, "IMultiLanguage2_GetCharsetInfo failed: %08x\n", ret
);
627 trace("%s: %u %u %s\n", wine_dbgstr_w(cpinfo
[i
].wszHeaderCharset
), mcsi
.uiCodePage
, mcsi
.uiInternetEncoding
, wine_dbgstr_w(mcsi
.wszCharset
));
629 ok(!lstrcmpiW(cpinfo
[i
].wszHeaderCharset
, mcsi
.wszCharset
), "%s != %s\n",
630 wine_dbgstr_w(cpinfo
[i
].wszHeaderCharset
), wine_dbgstr_w(mcsi
.wszCharset
));
634 /* native mlang returns completely messed up encodings in some cases */
635 ok(mcsi
.uiInternetEncoding
== cpinfo
[i
].uiCodePage
|| mcsi
.uiInternetEncoding
== cpinfo
[i
].uiFamilyCodePage
,
636 "%u != %u || %u\n", mcsi
.uiInternetEncoding
, cpinfo
[i
].uiCodePage
, cpinfo
[i
].uiFamilyCodePage
);
637 ok(mcsi
.uiCodePage
== cpinfo
[i
].uiCodePage
|| mcsi
.uiCodePage
== cpinfo
[i
].uiFamilyCodePage
,
638 "%u != %u || %u\n", mcsi
.uiCodePage
, cpinfo
[i
].uiCodePage
, cpinfo
[i
].uiFamilyCodePage
);
643 if (memcmp(cpinfo
[i
].wszBodyCharset
,feffW
,sizeof(WCHAR
)*11)==0)
644 skip("Legacy windows bug returning invalid charset of unicodeFEFF\n");
647 ret
= IMultiLanguage2_GetCharsetInfo(iML2
, cpinfo
[i
].wszBodyCharset
, &mcsi
);
648 /* _autoxxx charsets are a fake and GetCharsetInfo fails for them */
649 if (memcmp(cpinfo
[i
].wszBodyCharset
, autoW
, 5 * sizeof(WCHAR
)))
651 ok (ret
== S_OK
, "IMultiLanguage2_GetCharsetInfo failed: %08x\n", ret
);
653 trace("%s: %u %u %s\n", wine_dbgstr_w(cpinfo
[i
].wszBodyCharset
), mcsi
.uiCodePage
, mcsi
.uiInternetEncoding
, wine_dbgstr_w(mcsi
.wszCharset
));
655 ok(!lstrcmpiW(cpinfo
[i
].wszBodyCharset
, mcsi
.wszCharset
), "%s != %s\n",
656 wine_dbgstr_w(cpinfo
[i
].wszBodyCharset
), wine_dbgstr_w(mcsi
.wszCharset
));
660 /* native mlang returns completely messed up encodings in some cases */
661 ok(mcsi
.uiInternetEncoding
== cpinfo
[i
].uiCodePage
|| mcsi
.uiInternetEncoding
== cpinfo
[i
].uiFamilyCodePage
,
662 "%u != %u || %u\n", mcsi
.uiInternetEncoding
, cpinfo
[i
].uiCodePage
, cpinfo
[i
].uiFamilyCodePage
);
663 ok(mcsi
.uiCodePage
== cpinfo
[i
].uiCodePage
|| mcsi
.uiCodePage
== cpinfo
[i
].uiFamilyCodePage
,
664 "%u != %u || %u\n", mcsi
.uiCodePage
, cpinfo
[i
].uiCodePage
, cpinfo
[i
].uiFamilyCodePage
);
670 /* now IEnumCodePage_Next should fail, since pointer is at the end */
672 ret
= IEnumCodePage_Next(iEnumCP
, 1, &cpinfo2
, &n
);
673 ok(ret
== S_FALSE
&& n
== 0, "IEnumCodePage_Next: expected S_FALSE/0, got %08x/%u\n", ret
, n
);
675 ret
= IEnumCodePage_Reset(iEnumCP
);
676 ok(ret
== S_OK
, "IEnumCodePage_Reset: expected S_OK, got %08x\n", ret
);
678 ret
= IEnumCodePage_Next(iEnumCP
, 1, &cpinfo2
, &n
);
679 ok(n
== 1 && ret
== S_OK
, "IEnumCodePage_Next: expected 1/S_OK, got %u/%08x\n", n
, ret
);
680 cpinfo_cmp(&cpinfo
[0], &cpinfo2
);
684 /* Due to a bug in MS' implementation of IEnumCodePage_Skip
685 * it's not used here.
687 ret
= IEnumCodePage_Skip(iEnumCP
, 1);
688 ok(ret
== S_OK
, "IEnumCodePage_Skip: expected S_OK, got %08x\n", ret
);
690 for (i
= 0; i
< total
- 1; i
++)
693 ret
= IEnumCodePage_Next(iEnumCP
, 1, &cpinfo2
, &n
);
694 ok(n
== 1 && ret
== S_OK
, "IEnumCodePage_Next: expected 1/S_OK, got %u/%08x\n", n
, ret
);
695 cpinfo_cmp(&cpinfo
[i
+ 1], &cpinfo2
);
698 HeapFree(GetProcessHeap(), 0, cpinfo
);
699 IEnumCodePage_Release(iEnumCP
);
702 static void scriptinfo_cmp(SCRIPTINFO
*sinfo1
, SCRIPTINFO
*sinfo2
)
704 ok(sinfo1
->ScriptId
== sinfo2
->ScriptId
, "ScriptId mismatch: %d != %d\n", sinfo1
->ScriptId
, sinfo2
->ScriptId
);
705 ok(sinfo1
->uiCodePage
== sinfo2
->uiCodePage
, "uiCodePage mismatch: %u != %u\n", sinfo1
->uiCodePage
, sinfo2
->uiCodePage
);
706 ok(!lstrcmpW(sinfo1
->wszDescription
, sinfo2
->wszDescription
), "wszDescription mismatch\n");
707 ok(!lstrcmpW(sinfo1
->wszFixedWidthFont
, sinfo2
->wszFixedWidthFont
), "wszFixedWidthFont mismatch\n");
708 ok(!lstrcmpW(sinfo1
->wszProportionalFont
, sinfo2
->wszProportionalFont
), "wszProportionalFont mismatch\n");
711 static void test_EnumScripts(IMultiLanguage2
*iML2
, DWORD flags
)
713 IEnumScript
*iEnumScript
= NULL
;
721 ret
= IMultiLanguage2_GetNumberOfScripts(iML2
, &total
);
722 ok(ret
== S_OK
&& total
!= 0, "IMultiLanguage2_GetNumberOfScripts: expected S_OK/!0, got %08x/%u\n", ret
, total
);
724 trace("total mlang supported scripts %u\n", total
);
726 ret
= IMultiLanguage2_EnumScripts(iML2
, flags
, LANG_NEUTRAL
, &iEnumScript
);
727 ok(ret
== S_OK
&& iEnumScript
, "IMultiLanguage2_EnumScripts: expected S_OK/!NULL, got %08x/%p\n", ret
, iEnumScript
);
729 ret
= IEnumScript_Reset(iEnumScript
);
730 ok(ret
== S_OK
, "IEnumScript_Reset: expected S_OK, got %08x\n", ret
);
732 ret
= IEnumScript_Next(iEnumScript
, 0, NULL
, &n
);
733 ok(n
== 65536 && ret
== E_FAIL
, "IEnumScript_Next: expected 65536/E_FAIL, got %u/%08x\n", n
, ret
);
734 ret
= IEnumScript_Next(iEnumScript
, 0, NULL
, NULL
);
735 ok(ret
== E_FAIL
, "IEnumScript_Next: expected E_FAIL, got %08x\n", ret
);
737 sinfo
= HeapAlloc(GetProcessHeap(), 0, sizeof(*sinfo
) * total
* 2);
740 ret
= IEnumScript_Next(iEnumScript
, 0, sinfo
, &n
);
741 ok(ret
== S_FALSE
&& n
== 0, "IEnumScript_Next: expected S_FALSE/0, got %08x/%u\n", ret
, n
);
744 ret
= IEnumScript_Next(iEnumScript
, n
, sinfo
, &n
);
745 ok(ret
== S_OK
&& n
!= 0, "IEnumScript_Next: expected S_OK, got %08x/%u\n", ret
, n
);
747 trace("flags %08x, enumerated scripts %u\n", flags
, n
);
751 ok(n
== total
, "IEnumScript_Next: expected %u, got %u\n", total
, n
);
756 for (i
= 0; pGetCPInfoExA
&& i
< n
; i
++)
758 #ifdef DUMP_SCRIPT_INFO
759 trace("SCRIPTINFO #%u:\n"
762 "wszDescription %s\n"
763 "wszFixedWidthFont %s\n"
764 "wszProportionalFont %s\n\n",
768 wine_dbgstr_w(sinfo
[i
].wszDescription
),
769 wine_dbgstr_w(sinfo
[i
].wszFixedWidthFont
),
770 wine_dbgstr_w(sinfo
[i
].wszProportionalFont
));
771 trace("%u codepage %u\n", i
, sinfo
[i
].uiCodePage
);
775 /* now IEnumScript_Next should fail, since pointer is at the end */
777 ret
= IEnumScript_Next(iEnumScript
, 1, &sinfo2
, &n
);
778 ok(ret
== S_FALSE
&& n
== 0, "IEnumScript_Next: expected S_FALSE/0, got %08x/%u\n", ret
, n
);
780 ret
= IEnumScript_Reset(iEnumScript
);
781 ok(ret
== S_OK
, "IEnumScript_Reset: expected S_OK, got %08x\n", ret
);
783 ret
= IEnumScript_Next(iEnumScript
, 1, &sinfo2
, &n
);
784 ok(n
== 1 && ret
== S_OK
, "IEnumScript_Next: expected 1/S_OK, got %u/%08x\n", n
, ret
);
785 scriptinfo_cmp(&sinfo
[0], &sinfo2
);
789 /* Due to a bug in MS' implementation of IEnumScript_Skip
790 * it's not used here.
792 ret
= IEnumScript_Skip(iEnumScript
, 1);
793 ok(ret
== S_OK
, "IEnumScript_Skip: expected S_OK, got %08x\n", ret
);
795 for (i
= 0; i
< total
- 1; i
++)
798 ret
= IEnumScript_Next(iEnumScript
, 1, &sinfo2
, &n
);
799 ok(n
== 1 && ret
== S_OK
, "IEnumScript_Next: expected 1/S_OK, got %u/%08x\n", n
, ret
);
800 scriptinfo_cmp(&sinfo
[i
+ 1], &sinfo2
);
803 HeapFree(GetProcessHeap(), 0, sinfo
);
804 IEnumScript_Release(iEnumScript
);
807 static void IMLangFontLink_Test(IMLangFontLink
* iMLFL
)
809 DWORD dwCodePages
, dwManyCodePages
;
810 DWORD dwCmpCodePages
;
812 static const WCHAR str
[3] = { 'd', 0x0436, 0xff90 };
817 ret
= IMLangFontLink_CodePageToCodePages(iMLFL
, -1, &dwCodePages
);
818 ok(ret
== E_FAIL
, "IMLangFontLink_CodePageToCodePages should fail: %x\n", ret
);
819 ok(dwCodePages
== 0, "expected 0, got %u\n", dwCodePages
);
822 ret
= IMLangFontLink_CodePageToCodePages(iMLFL
, 932, &dwCodePages
);
823 ok(ret
== S_OK
, "IMLangFontLink_CodePageToCodePages error %x\n", ret
);
824 ok(dwCodePages
== FS_JISJAPAN
, "expected FS_JISJAPAN, got %08x\n", dwCodePages
);
826 ret
= IMLangFontLink_CodePagesToCodePage(iMLFL
, dwCodePages
, 1035, &CodePage
);
827 ok(ret
== S_OK
, "IMLangFontLink_CodePagesToCodePage error %x\n", ret
);
828 ok(CodePage
== 932, "Incorrect CodePage Returned (%i)\n",CodePage
);
831 ret
= IMLangFontLink_CodePageToCodePages(iMLFL
, 1252, &dwManyCodePages
);
832 ok(ret
== S_OK
, "IMLangFontLink_CodePageToCodePages error %x\n", ret
);
833 ok(dwManyCodePages
== FS_LATIN1
, "expected FS_LATIN1, got %08x\n", dwManyCodePages
);
835 ret
= IMLangFontLink_CodePageToCodePages(iMLFL
, 1256, &dwCodePages
);
836 ok(ret
== S_OK
, "IMLangFontLink_CodePageToCodePages error %x\n", ret
);
837 ok(dwCodePages
== FS_ARABIC
, "expected FS_ARABIC, got %08x\n", dwCodePages
);
838 dwManyCodePages
|= dwCodePages
;
839 ret
= IMLangFontLink_CodePageToCodePages(iMLFL
, 874, &dwCodePages
);
840 ok(ret
== S_OK
, "IMLangFontLink_CodePageToCodePages error %x\n", ret
);
841 ok(dwCodePages
== FS_THAI
, "expected FS_THAI, got %08x\n", dwCodePages
);
842 dwManyCodePages
|= dwCodePages
;
844 ret
= IMLangFontLink_CodePagesToCodePage(iMLFL
, dwManyCodePages
, 1256, &CodePage
);
845 ok(ret
== S_OK
, "IMLangFontLink_CodePagesToCodePage error %x\n", ret
);
846 ok(CodePage
== 1256, "Incorrect CodePage Returned (%i)\n",CodePage
);
848 ret
= IMLangFontLink_CodePagesToCodePage(iMLFL
, dwManyCodePages
, 936, &CodePage
);
849 ok(ret
== S_OK
, "IMLangFontLink_CodePagesToCodePage error %x\n", ret
);
850 ok(CodePage
== 1252, "Incorrect CodePage Returned (%i)\n",CodePage
);
852 /* Tests for GetCharCodePages */
855 dwCmpCodePages
= FS_LATIN1
| FS_LATIN2
| FS_CYRILLIC
| FS_GREEK
| FS_TURKISH
856 | FS_HEBREW
| FS_ARABIC
| FS_BALTIC
| FS_VIETNAMESE
| FS_THAI
857 | FS_JISJAPAN
| FS_CHINESESIMP
| FS_WANSUNG
| FS_CHINESETRAD
;
858 ret
= IMLangFontLink_GetCharCodePages(iMLFL
, 'd', &dwCodePages
);
859 ok(ret
== S_OK
, "IMLangFontLink_GetCharCodePages error %x\n", ret
);
860 ok(dwCodePages
== dwCmpCodePages
, "expected %x, got %x\n", dwCmpCodePages
, dwCodePages
);
864 ret
= IMLangFontLink_GetStrCodePages(iMLFL
, &str
[0], 1, 0, &dwCodePages
, &processed
);
865 ok(ret
== S_OK
, "IMLangFontLink_GetStrCodePages error %x\n", ret
);
866 ok(dwCodePages
== dwCmpCodePages
, "expected %x, got %x\n", dwCmpCodePages
, dwCodePages
);
867 ok(processed
== 1, "expected 1, got %d\n", processed
);
870 dwCmpCodePages
= FS_CYRILLIC
| FS_JISJAPAN
| FS_CHINESESIMP
| FS_WANSUNG
;
871 ret
= IMLangFontLink_GetCharCodePages(iMLFL
, 0x0436, &dwCodePages
);
872 ok(ret
== S_OK
, "IMLangFontLink_GetCharCodePages error %x\n", ret
);
873 ok(dwCodePages
== dwCmpCodePages
, "expected %x, got %x\n", dwCmpCodePages
, dwCodePages
);
877 ret
= IMLangFontLink_GetStrCodePages(iMLFL
, &str
[1], 1, 0, &dwCodePages
, &processed
);
878 ok(ret
== S_OK
, "IMLangFontLink_GetStrCodePages error %x\n", ret
);
879 ok(dwCodePages
== dwCmpCodePages
, "expected %x, got %x\n", dwCmpCodePages
, dwCodePages
);
880 ok(processed
== 1, "expected 1, got %d\n", processed
);
883 dwCmpCodePages
= FS_JISJAPAN
;
884 ret
= IMLangFontLink_GetCharCodePages(iMLFL
, 0xff90, &dwCodePages
);
885 ok(ret
== S_OK
, "IMLangFontLink_GetCharCodePages error %x\n", ret
);
886 ok(dwCodePages
== dwCmpCodePages
, "expected %x, got %x\n", dwCmpCodePages
, dwCodePages
);
890 ret
= IMLangFontLink_GetStrCodePages(iMLFL
, &str
[2], 1, 0, &dwCodePages
, &processed
);
891 ok(ret
== S_OK
, "IMLangFontLink_GetStrCodePages error %x\n", ret
);
892 ok(dwCodePages
== dwCmpCodePages
, "expected %x, got %x\n", dwCmpCodePages
, dwCodePages
);
893 ok(processed
== 1, "expected 1, got %d\n", processed
);
895 dwCmpCodePages
= FS_CYRILLIC
| FS_JISJAPAN
| FS_CHINESESIMP
| FS_WANSUNG
;
898 ret
= IMLangFontLink_GetStrCodePages(iMLFL
, str
, 2, 0, &dwCodePages
, &processed
);
899 ok(ret
== S_OK
, "IMLangFontLink_GetStrCodePages error %x\n", ret
);
900 ok(dwCodePages
== dwCmpCodePages
, "expected %x, got %x\n", dwCmpCodePages
, dwCodePages
);
901 ok(processed
== 2, "expected 2, got %d\n", processed
);
903 dwCmpCodePages
= FS_JISJAPAN
;
906 ret
= IMLangFontLink_GetStrCodePages(iMLFL
, str
, 3, 0, &dwCodePages
, &processed
);
907 ok(ret
== S_OK
, "IMLangFontLink_GetStrCodePages error %x\n", ret
);
908 ok(dwCodePages
== dwCmpCodePages
, "expected %x, got %x\n", dwCmpCodePages
, dwCodePages
);
909 ok(processed
== 3, "expected 3, got %d\n", processed
);
911 dwCodePages
= 0xffff;
913 ret
= IMLangFontLink_GetStrCodePages(iMLFL
, &str
[2], 1, 0, &dwCodePages
, &processed
);
914 ok(ret
== S_OK
, "IMLangFontLink_GetStrCodePages error %x\n", ret
);
915 ok(dwCodePages
== dwCmpCodePages
, "expected %x, got %x\n", dwCmpCodePages
, dwCodePages
);
916 ok(processed
== 1, "expected 0, got %d\n", processed
);
918 ret
= IMLangFontLink_GetStrCodePages(iMLFL
, &str
[2], 1, 0, NULL
, NULL
);
919 ok(ret
== S_OK
, "IMLangFontLink_GetStrCodePages error %x\n", ret
);
921 dwCodePages
= 0xffff;
923 ret
= IMLangFontLink_GetStrCodePages(iMLFL
, str
, -1, 0, &dwCodePages
, &processed
);
924 ok(ret
== E_INVALIDARG
, "IMLangFontLink_GetStrCodePages should fail: %x\n", ret
);
925 ok(dwCodePages
== 0, "expected %x, got %x\n", dwCmpCodePages
, dwCodePages
);
926 ok(processed
== 0, "expected 0, got %d\n", processed
);
928 dwCodePages
= 0xffff;
930 ret
= IMLangFontLink_GetStrCodePages(iMLFL
, NULL
, 1, 0, &dwCodePages
, &processed
);
931 ok(ret
== E_INVALIDARG
, "IMLangFontLink_GetStrCodePages should fail: %x\n", ret
);
932 ok(dwCodePages
== 0, "expected %x, got %x\n", dwCmpCodePages
, dwCodePages
);
933 ok(processed
== 0, "expected 0, got %d\n", processed
);
935 dwCodePages
= 0xffff;
937 ret
= IMLangFontLink_GetStrCodePages(iMLFL
, str
, 0, 0, &dwCodePages
, &processed
);
938 ok(ret
== E_INVALIDARG
, "IMLangFontLink_GetStrCodePages should fail: %x\n", ret
);
939 ok(dwCodePages
== 0, "expected %x, got %x\n", dwCmpCodePages
, dwCodePages
);
940 ok(processed
== 0, "expected 0, got %d\n", processed
);
943 /* copied from libs/wine/string.c */
944 static WCHAR
*strstrW(const WCHAR
*str
, const WCHAR
*sub
)
948 const WCHAR
*p1
= str
, *p2
= sub
;
949 while (*p1
&& *p2
&& *p1
== *p2
) { p1
++; p2
++; }
950 if (!*p2
) return (WCHAR
*)str
;
956 static void test_rfc1766(IMultiLanguage2
*iML2
)
958 IEnumRfc1766
*pEnumRfc1766
;
964 ret
= IMultiLanguage2_EnumRfc1766(iML2
, LANG_NEUTRAL
, &pEnumRfc1766
);
965 ok(ret
== S_OK
, "IMultiLanguage2_EnumRfc1766 error %08x\n", ret
);
969 ret
= IEnumRfc1766_Next(pEnumRfc1766
, 1, &info
, &n
);
970 if (ret
!= S_OK
) break;
973 trace("lcid %04x rfc_name %s locale_name %s\n",
974 info
.lcid
, wine_dbgstr_w(info
.wszRfc1766
), wine_dbgstr_w(info
.wszLocaleName
));
977 ok(n
== 1, "couldn't fetch 1 RFC1766INFO structure\n");
979 /* verify the Rfc1766 value */
980 ret
= IMultiLanguage2_GetRfc1766FromLcid(iML2
, info
.lcid
, &rfcstr
);
981 ok(ret
== S_OK
, "Expected S_OK, got %08x\n", ret
);
983 /* not an exact 1:1 correspondence between lcid and rfc1766 in the
984 * mlang database, e.g., nb-no -> 1044 -> no */
985 ok(strstrW(info
.wszRfc1766
, rfcstr
) != NULL
,
986 "Expected matching locale names\n");
988 SysFreeString(rfcstr
);
990 IEnumRfc1766_Release(pEnumRfc1766
);
993 static void test_GetLcidFromRfc1766(IMultiLanguage2
*iML2
)
995 WCHAR rfc1766W
[MAX_RFC1766_NAME
+ 1];
1000 static WCHAR en
[] = { 'e','n',0 };
1001 static WCHAR en_them
[] = { 'e','n','-','t','h','e','m',0 };
1002 static WCHAR english
[] = { 'e','n','g','l','i','s','h',0 };
1005 for(i
= 0; i
< sizeof(lcid_table
) / sizeof(lcid_table
[0]); i
++) {
1007 MultiByteToWideChar(CP_ACP
, 0, lcid_table
[i
].rfc1766
, -1, rfc1766W
, MAX_RFC1766_NAME
);
1008 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, &lcid
, rfc1766W
);
1010 /* IE <6.0 guess 0x412 (ko) from "kok" */
1011 ok((ret
== lcid_table
[i
].hr
) ||
1012 broken(lcid_table
[i
].broken_lcid
&& (ret
== S_FALSE
)),
1013 "#%02d: HRESULT 0x%x (expected 0x%x)\n", i
, ret
, lcid_table
[i
].hr
);
1015 ok((lcid
== lcid_table
[i
].lcid
) ||
1016 broken(lcid
== lcid_table
[i
].broken_lcid
), /* IE <6.0 */
1017 "#%02d: got LCID 0x%x (expected 0x%x)\n", i
, lcid
, lcid_table
[i
].lcid
);
1021 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, NULL
, en
);
1022 ok(ret
== E_INVALIDARG
, "GetLcidFromRfc1766 returned: %08x\n", ret
);
1024 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, &lcid
, NULL
);
1025 ok(ret
== E_INVALIDARG
, "GetLcidFromRfc1766 returned: %08x\n", ret
);
1027 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, &lcid
, en_them
);
1028 ok((ret
== E_FAIL
|| ret
== S_FALSE
), "GetLcidFromRfc1766 returned: %08x\n", ret
);
1032 static WCHAR en
[] = {'e','n',0};
1034 ret
= IMultiLanguage2_GetRfc1766FromLcid(iML2
, lcid
, &rfcstr
);
1035 ok(ret
== S_OK
, "Expected S_OK, got %08x\n", ret
);
1036 ok_w2("Expected \"%s\", got \"%s\"n", en
, rfcstr
);
1039 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, &lcid
, english
);
1040 ok((ret
== E_FAIL
|| ret
== S_FALSE
), "GetLcidFromRfc1766 returned: %08x\n", ret
);
1044 static WCHAR en
[] = {'e','n',0};
1046 ret
= IMultiLanguage2_GetRfc1766FromLcid(iML2
, lcid
, &rfcstr
);
1047 ok(ret
== S_OK
, "Expected S_OK, got %08x\n", ret
);
1048 ok_w2("Expected \"%s\", got \"%s\"n", en
, rfcstr
);
1053 static void test_Rfc1766ToLcid(void)
1059 for(i
= 0; i
< sizeof(lcid_table
) / sizeof(lcid_table
[0]); i
++) {
1061 ret
= pRfc1766ToLcidA(&lcid
, lcid_table
[i
].rfc1766
);
1063 /* IE <6.0 guess 0x412 (ko) from "kok" */
1064 ok( (ret
== lcid_table
[i
].hr
) ||
1065 broken(lcid_table
[i
].broken_lcid
&& (ret
== S_FALSE
)),
1066 "#%02d: HRESULT 0x%x (expected 0x%x)\n", i
, ret
, lcid_table
[i
].hr
);
1068 ok( (lcid
== lcid_table
[i
].lcid
) ||
1069 broken(lcid
== lcid_table
[i
].broken_lcid
), /* IE <6.0 */
1070 "#%02d: got LCID 0x%x (expected 0x%x)\n", i
, lcid
, lcid_table
[i
].lcid
);
1073 ret
= pRfc1766ToLcidA(&lcid
, NULL
);
1074 ok(ret
== E_INVALIDARG
, "got 0x%08x (expected E_INVALIDARG)\n", ret
);
1076 ret
= pRfc1766ToLcidA(NULL
, "en");
1077 ok(ret
== E_INVALIDARG
, "got 0x%08x (expected E_INVALIDARG)\n", ret
);
1080 static void test_GetNumberOfCodePageInfo(IMultiLanguage2
*iML2
)
1086 hr
= IMultiLanguage2_GetNumberOfCodePageInfo(iML2
, &value
);
1087 ok( (hr
== S_OK
) && value
,
1088 "got 0x%x with %d (expected S_OK with '!= 0')\n", hr
, value
);
1090 hr
= IMultiLanguage2_GetNumberOfCodePageInfo(iML2
, NULL
);
1091 ok(hr
== E_INVALIDARG
, "got 0x%x (expected E_INVALIDARG)\n", hr
);
1095 static void test_GetRfc1766FromLcid(IMultiLanguage2
*iML2
)
1097 CHAR expected
[MAX_RFC1766_NAME
];
1098 CHAR buffer
[MAX_RFC1766_NAME
+ 1];
1103 for(i
= 0; i
< sizeof(lcid_table
) / sizeof(lcid_table
[0]); i
++) {
1107 hr
= IMultiLanguage2_GetRfc1766FromLcid(iML2
, lcid_table
[i
].lcid
, &rfcstr
);
1108 ok(hr
== lcid_table
[i
].hr
,
1109 "#%02d: HRESULT 0x%x (expected 0x%x)\n", i
, hr
, lcid_table
[i
].hr
);
1112 continue; /* no result-string created */
1114 WideCharToMultiByte(CP_ACP
, 0, rfcstr
, -1, buffer
, sizeof(buffer
), NULL
, NULL
);
1115 LCMapStringA(LOCALE_USER_DEFAULT
, LCMAP_LOWERCASE
, lcid_table
[i
].rfc1766
,
1116 lstrlenA(lcid_table
[i
].rfc1766
) + 1, expected
, MAX_RFC1766_NAME
);
1118 /* IE <6.0 return "x-kok" for LCID 0x457 ("kok") */
1119 ok( (!lstrcmpA(buffer
, expected
)) ||
1120 broken(!lstrcmpA(buffer
, lcid_table
[i
].broken_rfc
)),
1121 "#%02d: got '%s' (expected '%s')\n", i
, buffer
, expected
);
1123 SysFreeString(rfcstr
);
1126 hr
= IMultiLanguage2_GetRfc1766FromLcid(iML2
, MAKELANGID(LANG_ENGLISH
, SUBLANG_ENGLISH_US
), NULL
);
1127 ok(hr
== E_INVALIDARG
, "got 0x%x (expected E_INVALIDARG)\n", hr
);
1130 static void test_LcidToRfc1766(void)
1132 CHAR expected
[MAX_RFC1766_NAME
];
1133 CHAR buffer
[MAX_RFC1766_NAME
* 2];
1137 for(i
= 0; i
< sizeof(lcid_table
) / sizeof(lcid_table
[0]); i
++) {
1139 memset(buffer
, '#', sizeof(buffer
)-1);
1140 buffer
[sizeof(buffer
)-1] = '\0';
1142 hr
= pLcidToRfc1766A(lcid_table
[i
].lcid
, buffer
, MAX_RFC1766_NAME
);
1144 /* IE <5.0 does not recognize 0x180c (fr-mc) and 0x457 (kok) */
1145 ok( (hr
== lcid_table
[i
].hr
) ||
1146 broken(lcid_table
[i
].broken_lcid
&& (hr
== E_FAIL
)),
1147 "#%02d: HRESULT 0x%x (expected 0x%x)\n", i
, hr
, lcid_table
[i
].hr
);
1152 LCMapStringA(LOCALE_USER_DEFAULT
, LCMAP_LOWERCASE
, lcid_table
[i
].rfc1766
,
1153 lstrlenA(lcid_table
[i
].rfc1766
) + 1, expected
, MAX_RFC1766_NAME
);
1155 /* IE <6.0 return "x-kok" for LCID 0x457 ("kok") */
1156 /* IE <5.0 return "fr" for LCID 0x180c ("fr-mc") */
1157 ok( (!lstrcmpA(buffer
, expected
)) ||
1158 broken(!lstrcmpA(buffer
, lcid_table
[i
].broken_rfc
)),
1159 "#%02d: got '%s' (expected '%s')\n", i
, buffer
, expected
);
1163 memset(buffer
, '#', sizeof(buffer
)-1);
1164 buffer
[sizeof(buffer
)-1] = '\0';
1165 hr
= pLcidToRfc1766A(-1, buffer
, MAX_RFC1766_NAME
);
1166 ok(hr
== E_FAIL
, "got 0x%08x and '%s' (expected E_FAIL)\n", hr
, buffer
);
1168 hr
= pLcidToRfc1766A(LANG_ENGLISH
, NULL
, MAX_RFC1766_NAME
);
1169 ok(hr
== E_INVALIDARG
, "got 0x%08x (expected E_INVALIDARG)\n", hr
);
1171 memset(buffer
, '#', sizeof(buffer
)-1);
1172 buffer
[sizeof(buffer
)-1] = '\0';
1173 hr
= pLcidToRfc1766A(LANG_ENGLISH
, buffer
, -1);
1174 ok(hr
== E_INVALIDARG
, "got 0x%08x and '%s' (expected E_INVALIDARG)\n", hr
, buffer
);
1176 memset(buffer
, '#', sizeof(buffer
)-1);
1177 buffer
[sizeof(buffer
)-1] = '\0';
1178 hr
= pLcidToRfc1766A(LANG_ENGLISH
, buffer
, 0);
1179 ok(hr
== E_INVALIDARG
, "got 0x%08x and '%s' (expected E_INVALIDARG)\n", hr
, buffer
);
1182 static void test_GetRfc1766Info(IMultiLanguage2
*iML2
)
1184 WCHAR short_broken_name
[MAX_LOCALE_NAME
];
1185 CHAR rfc1766A
[MAX_RFC1766_NAME
+ 1];
1186 BYTE buffer
[sizeof(RFC1766INFO
) + 4];
1187 PRFC1766INFO prfc
= (RFC1766INFO
*) buffer
;
1191 for(i
= 0; i
< sizeof(info_table
) / sizeof(info_table
[0]); i
++) {
1192 memset(buffer
, 'x', sizeof(RFC1766INFO
) + 2);
1193 buffer
[sizeof(buffer
) -1] = 0;
1194 buffer
[sizeof(buffer
) -2] = 0;
1196 ret
= IMultiLanguage2_GetRfc1766Info(iML2
, info_table
[i
].lcid
, info_table
[i
].lang
, prfc
);
1197 WideCharToMultiByte(CP_ACP
, 0, prfc
->wszRfc1766
, -1, rfc1766A
, MAX_RFC1766_NAME
, NULL
, NULL
);
1198 ok(ret
== S_OK
, "#%02d: got 0x%x (expected S_OK)\n", i
, ret
);
1199 ok(prfc
->lcid
== info_table
[i
].lcid
,
1200 "#%02d: got 0x%04x (expected 0x%04x)\n", i
, prfc
->lcid
, info_table
[i
].lcid
);
1202 ok(!lstrcmpA(rfc1766A
, info_table
[i
].rfc1766
),
1203 "#%02d: got '%s' (expected '%s')\n", i
, rfc1766A
, info_table
[i
].rfc1766
);
1205 /* Some IE versions truncate an oversized name one character to short */
1206 lstrcpyW(short_broken_name
, info_table
[i
].broken_name
);
1207 short_broken_name
[MAX_LOCALE_NAME
- 2] = '\0';
1209 if (info_table
[i
].todo
& TODO_NAME
) {
1211 ok( (!lstrcmpW(prfc
->wszLocaleName
, info_table
[i
].localename
)) ||
1212 broken(!lstrcmpW(prfc
->wszLocaleName
, info_table
[i
].broken_name
)) || /* IE < 6.0 */
1213 broken(!lstrcmpW(prfc
->wszLocaleName
, short_broken_name
)),
1214 "#%02d: got %s (expected %s)\n", i
,
1215 wine_dbgstr_w(prfc
->wszLocaleName
), wine_dbgstr_w(info_table
[i
].localename
));
1218 ok( (!lstrcmpW(prfc
->wszLocaleName
, info_table
[i
].localename
)) ||
1219 broken(!lstrcmpW(prfc
->wszLocaleName
, info_table
[i
].broken_name
)) || /* IE < 6.0 */
1220 broken(!lstrcmpW(prfc
->wszLocaleName
, short_broken_name
)),
1221 "#%02d: got %s (expected %s)\n", i
,
1222 wine_dbgstr_w(prfc
->wszLocaleName
), wine_dbgstr_w(info_table
[i
].localename
));
1226 /* SUBLANG_NEUTRAL only allowed for English, Arabic, Chinese */
1227 ret
= IMultiLanguage2_GetRfc1766Info(iML2
, MAKELANGID(LANG_GERMAN
, SUBLANG_NEUTRAL
), LANG_ENGLISH
, prfc
);
1228 ok(ret
== E_FAIL
, "got 0x%x (expected E_FAIL)\n", ret
);
1230 ret
= IMultiLanguage2_GetRfc1766Info(iML2
, MAKELANGID(LANG_ITALIAN
, SUBLANG_NEUTRAL
), LANG_ENGLISH
, prfc
);
1231 ok(ret
== E_FAIL
, "got 0x%x (expected E_FAIL)\n", ret
);
1233 /* NULL not allowed */
1234 ret
= IMultiLanguage2_GetRfc1766Info(iML2
, 0, LANG_ENGLISH
, prfc
);
1235 ok(ret
== E_FAIL
, "got 0x%x (expected E_FAIL)\n", ret
);
1237 ret
= IMultiLanguage2_GetRfc1766Info(iML2
, LANG_ENGLISH
, LANG_ENGLISH
, NULL
);
1238 ok(ret
== E_INVALIDARG
, "got 0x%x (expected E_INVALIDARG)\n", ret
);
1241 static void test_IMultiLanguage2_ConvertStringFromUnicode(IMultiLanguage2
*iML2
)
1243 CHAR dest
[MAX_PATH
];
1244 CHAR invariate
[MAX_PATH
];
1248 static WCHAR src
[] = {'a','b','c',0};
1250 memset(invariate
, 'x', sizeof(invariate
));
1253 memset(dest
, 'x', sizeof(dest
));
1254 srcsz
= lstrlenW(src
) + 1;
1255 destsz
= sizeof(dest
);
1256 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, NULL
,
1257 &srcsz
, dest
, &destsz
);
1258 ok(hr
== S_OK
|| hr
== E_FAIL
,"expected S_OK or E_FAIL, got %08x\n",hr
);
1261 ok(srcsz
== lstrlenW(src
) + 1,
1262 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1264 else if (hr
== E_FAIL
)
1267 "Expected %u, got %u\n", 0, srcsz
);
1270 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1271 "Expected dest to be unchanged, got %s\n", dest
);
1272 ok(destsz
== 0, "Expected 0, got %u\n", destsz
);
1274 /* pcSrcSize NULL */
1275 memset(dest
, 'x', sizeof(dest
));
1276 destsz
= sizeof(dest
);
1277 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
1278 NULL
, dest
, &destsz
);
1279 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1280 ok(!strncmp(dest
, "abc", 3),
1281 "Expected first three chars to be \"abc\"\n");
1282 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
1283 "Expected rest of dest to be unchanged, got %s\n", dest
);
1284 ok(destsz
== lstrlenW(src
),
1285 "Expected %u, got %u\n", lstrlenW(src
), destsz
);
1287 /* both pSrcStr and pcSrcSize NULL */
1288 memset(dest
, 'x', sizeof(dest
));
1289 destsz
= sizeof(dest
);
1290 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, NULL
,
1291 NULL
, dest
, &destsz
);
1292 ok(hr
== S_OK
|| hr
== E_FAIL
, "Expected S_OK or E_FAIL, got %08x\n", hr
);
1293 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1294 "Expected dest to be unchanged, got %s\n", dest
);
1295 ok(destsz
== 0, "Expected 0, got %u\n", destsz
);
1298 memset(dest
, 'x', sizeof(dest
));
1299 srcsz
= lstrlenW(src
) + 1;
1300 destsz
= sizeof(dest
);
1301 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
1302 &srcsz
, NULL
, &destsz
);
1303 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1304 ok(srcsz
== lstrlenW(src
) + 1,
1305 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1306 ok(destsz
== lstrlenW(src
) + 1,
1307 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1309 /* pcDstSize NULL */
1310 memset(dest
, 'x', sizeof(dest
));
1311 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
1312 &srcsz
, dest
, NULL
);
1313 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1314 ok(srcsz
== lstrlenW(src
) + 1,
1315 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1316 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1317 "Expected dest to be unchanged, got %s\n", dest
);
1319 /* pcSrcSize is 0 */
1320 memset(dest
, 'x', sizeof(dest
));
1322 destsz
= sizeof(dest
);
1323 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
1324 &srcsz
, dest
, &destsz
);
1325 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1326 ok(srcsz
== 0, "Expected 0, got %u\n", srcsz
);
1327 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1328 "Expected dest to be unchanged, got %s\n", dest
);
1329 ok(destsz
== 0, "Expected 0, got %u\n", destsz
);
1331 /* pcSrcSize does not include NULL terminator */
1332 memset(dest
, 'x', sizeof(dest
));
1333 srcsz
= lstrlenW(src
);
1334 destsz
= sizeof(dest
);
1335 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
1336 &srcsz
, dest
, &destsz
);
1337 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1338 ok(srcsz
== lstrlenW(src
),
1339 "Expected %u, got %u\n", lstrlenW(src
), srcsz
);
1340 ok(!strncmp(dest
, "abc", 3), "Expected first three chars to be \"abc\"\n");
1341 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
1342 "Expected rest of dest to be unchanged, got %s\n", dest
);
1343 ok(destsz
== lstrlenW(src
),
1344 "Expected %u, got %u\n", lstrlenW(src
), destsz
);
1346 /* pcSrcSize includes NULL terminator */
1347 memset(dest
, 'x', sizeof(dest
));
1348 srcsz
= lstrlenW(src
) + 1;
1349 destsz
= sizeof(dest
);
1350 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
1351 &srcsz
, dest
, &destsz
);
1352 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1353 ok(srcsz
== lstrlenW(src
) + 1, "Expected 3, got %u\n", srcsz
);
1354 ok(!lstrcmpA(dest
, "abc"), "Expected \"abc\", got \"%s\"\n", dest
);
1355 ok(destsz
== lstrlenW(src
) + 1,
1356 "Expected %u, got %u\n", lstrlenW(src
) + 1, destsz
);
1358 /* pcSrcSize is -1 */
1359 memset(dest
, 'x', sizeof(dest
));
1361 destsz
= sizeof(dest
);
1362 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
1363 &srcsz
, dest
, &destsz
);
1364 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1365 ok(srcsz
== lstrlenW(src
),
1366 "Expected %u, got %u\n", lstrlenW(src
), srcsz
);
1367 ok(!strncmp(dest
, "abc", 3), "Expected first three chars to be \"abc\"\n");
1368 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
1369 "Expected rest of dest to be unchanged, got %s\n", dest
);
1370 ok(destsz
== lstrlenW(src
),
1371 "Expected %u, got %u\n", lstrlenW(src
), destsz
);
1373 /* pcDstSize is 0 */
1374 memset(dest
, 'x', sizeof(dest
));
1375 srcsz
= lstrlenW(src
) + 1;
1377 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
1378 &srcsz
, dest
, &destsz
);
1379 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1380 ok(srcsz
== lstrlenW(src
) + 1,
1381 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1382 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1383 "Expected dest to be unchanged, got %s\n", dest
);
1384 ok(destsz
== lstrlenW(src
) + 1,
1385 "Expected %u, got %u\n", lstrlenW(src
) + 1, destsz
);
1387 /* pcDstSize is not large enough */
1388 memset(dest
, 'x', sizeof(dest
));
1389 srcsz
= lstrlenW(src
) + 1;
1390 destsz
= lstrlenW(src
);
1391 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
1392 &srcsz
, dest
, &destsz
);
1393 ok(hr
== E_FAIL
, "Expected E_FAIL, got %08x\n", hr
);
1394 ok(srcsz
== 0, "Expected 0, got %u\n", srcsz
);
1395 ok(!strncmp(dest
, "abc", 3), "Expected first three chars to be \"abc\"\n");
1396 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
1397 "Expected rest of dest to be unchanged, got %s\n", dest
);
1398 ok(destsz
== 0, "Expected 0, got %u\n", srcsz
);
1400 /* pcDstSize (bytes) does not leave room for NULL terminator */
1401 memset(dest
, 'x', sizeof(dest
));
1402 srcsz
= lstrlenW(src
) + 1;
1403 destsz
= lstrlenW(src
) * sizeof(WCHAR
);
1404 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
1405 &srcsz
, dest
, &destsz
);
1406 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1407 ok(srcsz
== lstrlenW(src
) + 1,
1408 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1409 ok(!lstrcmpA(dest
, "abc"), "Expected \"abc\", got \"%s\"\n", dest
);
1410 ok(destsz
== lstrlenW(src
) + 1,
1411 "Expected %u, got %u\n", lstrlenW(src
) + 1, destsz
);
1414 static void test_ConvertINetUnicodeToMultiByte(void)
1416 CHAR dest
[MAX_PATH
];
1417 CHAR invariate
[MAX_PATH
];
1421 static WCHAR src
[] = {'a','b','c',0};
1423 memset(invariate
, 'x', sizeof(invariate
));
1426 memset(dest
, 'x', sizeof(dest
));
1427 srcsz
= lstrlenW(src
) + 1;
1428 destsz
= sizeof(dest
);
1429 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, NULL
, &srcsz
, dest
, &destsz
);
1430 ok(hr
== S_OK
|| hr
== E_FAIL
, "Expected S_OK or E_FAIL, got %08x\n", hr
);
1432 ok(srcsz
== lstrlenW(src
) + 1,
1433 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1434 else if (hr
== E_FAIL
)
1436 "Expected %u, got %u\n", 0, srcsz
);
1437 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1438 "Expected dest to be unchanged, got %s\n", dest
);
1439 ok(destsz
== 0, "Expected 0, got %u\n", destsz
);
1441 /* lpnWideCharCount NULL */
1442 memset(dest
, 'x', sizeof(dest
));
1443 destsz
= sizeof(dest
);
1444 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, NULL
, dest
, &destsz
);
1445 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1446 ok(!strncmp(dest
, "abc", 3),
1447 "Expected first three chars to be \"abc\"\n");
1448 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
1449 "Expected rest of dest to be unchanged, got %s\n", dest
);
1450 ok(destsz
== lstrlenW(src
),
1451 "Expected %u, got %u\n", lstrlenW(src
), destsz
);
1453 /* both lpSrcStr and lpnWideCharCount NULL */
1454 memset(dest
, 'x', sizeof(dest
));
1455 destsz
= sizeof(dest
);
1456 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, NULL
, NULL
, dest
, &destsz
);
1457 ok(hr
== S_OK
|| hr
== E_FAIL
, "Expected S_OK or E_FAIL, got %08x\n", hr
);
1458 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1459 "Expected dest to be unchanged, got %s\n", dest
);
1460 ok(destsz
== 0, "Expected 0, got %u\n", destsz
);
1463 memset(dest
, 'x', sizeof(dest
));
1464 srcsz
= lstrlenW(src
) + 1;
1465 destsz
= sizeof(dest
);
1466 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, NULL
, &destsz
);
1467 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1468 ok(srcsz
== lstrlenW(src
) + 1,
1469 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1470 ok(destsz
== lstrlenW(src
) + 1,
1471 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1473 /* lpnMultiCharCount NULL */
1474 memset(dest
, 'x', sizeof(dest
));
1475 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, NULL
);
1476 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1477 ok(srcsz
== lstrlenW(src
) + 1,
1478 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1479 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1480 "Expected dest to be unchanged, got %s\n", dest
);
1482 /* lpnWideCharCount is 0 */
1483 memset(dest
, 'x', sizeof(dest
));
1485 destsz
= sizeof(dest
);
1486 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, &destsz
);
1487 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1488 ok(srcsz
== 0, "Expected 0, got %u\n", srcsz
);
1489 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1490 "Expected dest to be unchanged, got %s\n", dest
);
1491 ok(destsz
== 0, "Expected 0, got %u\n", destsz
);
1493 /* lpnWideCharCount does not include NULL terminator */
1494 memset(dest
, 'x', sizeof(dest
));
1495 srcsz
= lstrlenW(src
);
1496 destsz
= sizeof(dest
);
1497 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, &destsz
);
1498 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1499 ok(srcsz
== lstrlenW(src
),
1500 "Expected %u, got %u\n", lstrlenW(src
), srcsz
);
1501 ok(!strncmp(dest
, "abc", 3), "Expected first three chars to be \"abc\"\n");
1502 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
1503 "Expected rest of dest to be unchanged, got %s\n", dest
);
1504 ok(destsz
== lstrlenW(src
),
1505 "Expected %u, got %u\n", lstrlenW(src
), destsz
);
1507 /* lpnWideCharCount includes NULL terminator */
1508 memset(dest
, 'x', sizeof(dest
));
1509 srcsz
= lstrlenW(src
) + 1;
1510 destsz
= sizeof(dest
);
1511 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, &destsz
);
1512 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1513 ok(srcsz
== lstrlenW(src
) + 1, "Expected 3, got %u\n", srcsz
);
1514 ok(!lstrcmpA(dest
, "abc"), "Expected \"abc\", got \"%s\"\n", dest
);
1515 ok(destsz
== lstrlenW(src
) + 1,
1516 "Expected %u, got %u\n", lstrlenW(src
) + 1, destsz
);
1518 /* lpnWideCharCount is -1 */
1519 memset(dest
, 'x', sizeof(dest
));
1521 destsz
= sizeof(dest
);
1522 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, &destsz
);
1523 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1524 ok(srcsz
== lstrlenW(src
),
1525 "Expected %u, got %u\n", lstrlenW(src
), srcsz
);
1526 ok(!strncmp(dest
, "abc", 3), "Expected first three chars to be \"abc\"\n");
1527 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
1528 "Expected rest of dest to be unchanged, got %s\n", dest
);
1529 ok(destsz
== lstrlenW(src
),
1530 "Expected %u, got %u\n", lstrlenW(src
), destsz
);
1532 /* lpnMultiCharCount is 0 */
1533 memset(dest
, 'x', sizeof(dest
));
1534 srcsz
= lstrlenW(src
) + 1;
1536 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, &destsz
);
1537 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1538 ok(srcsz
== lstrlenW(src
) + 1,
1539 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1540 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1541 "Expected dest to be unchanged, got %s\n", dest
);
1542 ok(destsz
== lstrlenW(src
) + 1,
1543 "Expected %u, got %u\n", lstrlenW(src
) + 1, destsz
);
1545 /* lpnMultiCharCount is not large enough */
1546 memset(dest
, 'x', sizeof(dest
));
1547 srcsz
= lstrlenW(src
) + 1;
1548 destsz
= lstrlenW(src
);
1549 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, &destsz
);
1550 ok(hr
== E_FAIL
, "Expected E_FAIL, got %08x\n", hr
);
1551 ok(srcsz
== 0, "Expected 0, got %u\n", srcsz
);
1552 ok(!strncmp(dest
, "abc", 3), "Expected first three chars to be \"abc\"\n");
1553 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
1554 "Expected rest of dest to be unchanged, got %s\n", dest
);
1555 ok(destsz
== 0, "Expected 0, got %u\n", srcsz
);
1557 /* lpnMultiCharCount (bytes) does not leave room for NULL terminator */
1558 memset(dest
, 'x', sizeof(dest
));
1559 srcsz
= lstrlenW(src
) + 1;
1560 destsz
= lstrlenW(src
) * sizeof(WCHAR
);
1561 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, &destsz
);
1562 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1563 ok(srcsz
== lstrlenW(src
) + 1,
1564 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1565 ok(!lstrcmpA(dest
, "abc"), "Expected \"abc\", got \"%s\"\n", dest
);
1566 ok(destsz
== lstrlenW(src
) + 1,
1567 "Expected %u, got %u\n", lstrlenW(src
) + 1, destsz
);
1570 static void test_JapaneseConversion(void)
1573 static WCHAR unc_jp
[9][12] = {
1574 {9,0x31,0x20,0x3042,0x3044,0x3046,0x3048,0x304a,0x000d,0x000a},
1575 {9,0x31,0x20,0x30a2,0x30a4,0x30a6,0x30a8,0x30aa,0x000d,0x000a},
1576 {9,0x31,0x20,0xff71,0xff72,0xff73,0xff74,0xff75,0x000d,0x000a},
1577 {9,0x31,0x20,0x3041,0x3043,0x3045,0x3047,0x3049,0x000d,0x000a},
1578 {9,0x31,0x20,0x30a1,0x30a3,0x30a5,0x30a7,0x30a9,0x000d,0x000a},
1579 {9,0x31,0x20,0xff67,0xff68,0xff69,0xff6a,0xff6b,0x000d,0x000a},
1580 {9,0x31,0x20,0x300c,0x65e5,0x672c,0x8a9e,0x300d,0x000d,0x000a},
1581 {7,0x31,0x20,0x25c7,0x25c7,0x3012,0x000d,0x000a},
1582 {11,0x31,0x20,0x203b,0x3010,0x0074,0x0065,0x0073,0x0074,0x3011,0x000d,0x000a}
1584 static CHAR jis_jp
[9][27] = {
1585 {20,0x31,0x20,0x1b,0x24,0x42,0x24,0x22,0x24,0x24,0x24,0x26,0x24,0x28,
1586 0x24,0x2a,0x1b,0x28,0x42,0x0d,0x0a},
1587 {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x22,0x25,0x24,0x25,0x26,0x25,0x28,
1588 0x25,0x2a,0x1b,0x28,0x42,0x0d,0x0a},
1589 {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x22,0x25,0x24,0x25,0x26,0x25,0x28,
1590 0x25,0x2a,0x1b,0x28,0x42,0x0d,0x0a},
1591 {20,0x31,0x20,0x1b,0x24,0x42,0x24,0x21,0x24,0x23,0x24,0x25,0x24,0x27,
1592 0x24,0x29,0x1b,0x28,0x42,0x0d,0x0a},
1593 {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x21,0x25,0x23,0x25,0x25,0x25,0x27,
1594 0x25,0x29,0x1b,0x28,0x42,0x0d,0x0a},
1595 {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x21,0x25,0x23,0x25,0x25,0x25,0x27,
1596 0x25,0x29,0x1b,0x28,0x42,0x0d,0x0a},
1597 {20,0x31,0x20,0x1b,0x24,0x42,0x21,0x56,0x46,0x7c,0x4b,0x5c,0x38,0x6c,
1598 0x21,0x57,0x1b,0x28,0x42,0x0d,0x0a},
1599 {16,0x31,0x20,0x1b,0x24,0x42,0x21,0x7e,0x21,0x7e,0x22,0x29,0x1b,0x28,
1601 {26,0x31,0x20,0x1b,0x24,0x42,0x22,0x28,0x21,0x5a,0x1b,0x28,0x42,0x74,
1602 0x65,0x73,0x74,0x1b,0x24,0x42,0x21,0x5b,0x1b,0x28,0x42,0x0d,0x0a}
1604 static CHAR sjis_jp
[9][15] = {
1605 {14,0x31,0x20,0x82,0xa0,0x82,0xa2,0x82,0xa4,0x82,0xa6,0x82,0xa8,0x0d,0x0a},
1606 {14,0x31,0x20,0x83,0x41,0x83,0x43,0x83,0x45,0x83,0x47,0x83,0x49,0x0d,0x0a},
1607 {9,0x31,0x20,0xb1,0xb2,0xb3,0xb4,0xb5,0x0d,0x0a},
1608 {14,0x31,0x20,0x82,0x9f,0x82,0xa1,0x82,0xa3,0x82,0xa5,0x82,0xa7,0x0d,0x0a},
1609 {14,0x31,0x20,0x83,0x40,0x83,0x42,0x83,0x44,0x83,0x46,0x83,0x48,0x0d,0x0a},
1610 {9,0x31,0x20,0xa7,0xa8,0xa9,0xaa,0xab,0x0d,0x0a},
1611 {14,0x31,0x20,0x81,0x75,0x93,0xfa,0x96,0x7b,0x8c,0xea,0x81,0x76,0x0d,0x0a},
1612 {10,0x31,0x20,0x81,0x9e,0x81,0x9e,0x81,0xa7,0x0d,0x0a},
1613 {14,0x31,0x20,0x81,0xa6,0x81,0x79,0x74,0x65,0x73,0x74,0x81,0x7a,0x0d,0x0a}
1615 static CHAR euc_jp
[9][15] = {
1616 {14,0x31,0x20,0xa4,0xa2,0xa4,0xa4,0xa4,0xa6,0xa4,0xa8,0xa4,0xaa,0x0d,0x0a},
1617 {14,0x31,0x20,0xa5,0xa2,0xa5,0xa4,0xa5,0xa6,0xa5,0xa8,0xa5,0xaa,0x0d,0x0a},
1618 {14,0x31,0x20,0x8e,0xb1,0x8e,0xb2,0x8e,0xb3,0x8e,0xb4,0x8e,0xb5,0x0d,0x0a},
1619 {14,0x31,0x20,0xa4,0xa1,0xa4,0xa3,0xa4,0xa5,0xa4,0xa7,0xa4,0xa9,0x0d,0x0a},
1620 {14,0x31,0x20,0xa5,0xa1,0xa5,0xa3,0xa5,0xa5,0xa5,0xa7,0xa5,0xa9,0x0d,0x0a},
1621 {14,0x31,0x20,0x8e,0xa7,0x8e,0xa8,0x8e,0xa9,0x8e,0xaa,0x8e,0xab,0x0d,0x0a},
1622 {14,0x31,0x20,0xa1,0xd6,0xc6,0xfc,0xcb,0xdc,0xb8,0xec,0xa1,0xd7,0x0d,0x0a},
1623 {10,0x31,0x20,0xa1,0xfe,0xa1,0xfe,0xa2,0xa9,0x0d,0x0a},
1624 {14,0x31,0x20,0xa2,0xa8,0xa1,0xda,0x74,0x65,0x73,0x74,0xa1,0xdb,0x0d,0x0a}
1635 for (i
= 0; i
< 9; i
++)
1639 outlen
= jis_jp
[i
][0];
1640 srcsz
= unc_jp
[i
][0];
1641 hr
= pConvertINetUnicodeToMultiByte(NULL
, 50220, &unc_jp
[i
][1], &srcsz
, output
, &destsz
);
1644 skip("Code page identifier 50220 is not supported\n");
1647 ok(hr
== S_OK
,"(%i) Expected S_OK, got %08x\n", i
, hr
);
1648 ok(destsz
== outlen
, "(%i) Expected %i, got %i\n",i
,outlen
,destsz
);
1649 ok(srcsz
== unc_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[i
][0],srcsz
);
1650 ok(memcmp(output
,&jis_jp
[i
][1],destsz
)==0,"(%i) Strings do not match\n",i
);
1655 hr
= pConvertINetMultiByteToUnicode(NULL
, 50220, output
, &srcsz
, outputW
,&destsz
);
1658 * JIS does not have hankata so it get automatically converted to
1659 * zenkata. this means that strings 1 and 2 are identical as well as
1666 ok(hr
== S_OK
,"(%i) Expected S_OK, got %08x\n",i
, hr
);
1667 ok(destsz
== unc_jp
[j
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[j
][0],destsz
);
1668 ok(srcsz
== outlen
,"(%i) Expected %i, got %i\n",i
,outlen
,srcsz
);
1669 ok(memcmp(outputW
,&unc_jp
[j
][1],destsz
)==0,"(%i) Strings do not match\n",i
);
1672 /* test unc->sjis */
1673 for (i
= 0; i
< 9; i
++)
1676 outlen
= sjis_jp
[i
][0];
1677 srcsz
= unc_jp
[i
][0];
1679 hr
= pConvertINetUnicodeToMultiByte(NULL
, 932, &unc_jp
[i
][1], &srcsz
, output
, &destsz
);
1682 skip("Code page identifier 932 is not supported\n");
1685 ok(hr
== S_OK
,"(%i) Expected S_OK, got %08x\n",i
,hr
);
1686 ok(destsz
== outlen
,"(%i) Expected %i, got %i\n",i
,outlen
,destsz
);
1687 ok(srcsz
== unc_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[i
][0],srcsz
);
1688 ok(memcmp(output
,&sjis_jp
[i
][1],outlen
)==0,"(%i) Strings do not match\n",i
);
1692 hr
= pConvertINetMultiByteToUnicode(NULL
, 932, output
, &srcsz
, outputW
,&destsz
);
1694 ok(hr
== S_OK
,"(%i) Expected S_OK, got %08x\n", i
, hr
);
1695 ok(destsz
== unc_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[i
][0],destsz
);
1696 ok(srcsz
== outlen
,"(%i) Expected %i, got %i\n",i
,outlen
,srcsz
);
1697 ok(memcmp(outputW
,&unc_jp
[i
][1],destsz
)==0,"(%i) Strings do not match\n",i
);
1701 for (i
= 0; i
< 9; i
++)
1704 outlen
= euc_jp
[i
][0];
1705 srcsz
= unc_jp
[i
][0];
1707 hr
= pConvertINetUnicodeToMultiByte(NULL
, 51932, &unc_jp
[i
][1], &srcsz
, output
, &destsz
);
1710 skip("Code page identifier 51932 is not supported\n");
1713 ok(hr
== S_OK
, "(%i) Expected S_OK, got %08x\n",i
,hr
);
1714 ok(destsz
== outlen
, "(%i) Expected %i, got %i\n",i
,outlen
,destsz
);
1715 ok(srcsz
== unc_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[i
][0],destsz
);
1716 ok(memcmp(output
,&euc_jp
[i
][1],outlen
)==0,"(%i) Strings do not match\n",i
);
1720 hr
= pConvertINetMultiByteToUnicode(NULL
, 51932, output
, &srcsz
, outputW
,&destsz
);
1722 ok(hr
== S_OK
,"(%i) Expected S_OK, got %08x\n",i
,hr
);
1723 ok(destsz
== unc_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[i
][0],destsz
);
1724 ok(srcsz
== outlen
,"(%i) Expected %i, got %i\n",i
,outlen
,srcsz
);
1725 ok(memcmp(outputW
,&unc_jp
[i
][1],destsz
)==0,"(%i) Strings do not match\n",i
);
1728 /* Japanese autodetect */
1731 srcsz
= jis_jp
[i
][0];
1732 hr
= pConvertINetMultiByteToUnicode(NULL
, 50932, &jis_jp
[i
][1], &srcsz
, outputW
, &destsz
);
1735 skip("Code page identifier 50932 is not supported\n");
1738 ok(hr
== S_OK
,"(%i) Expected S_OK, got %08x\n",i
,hr
);
1739 ok(destsz
== unc_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[i
][0],destsz
);
1740 ok(srcsz
== jis_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,jis_jp
[i
][0],srcsz
);
1741 ok(memcmp(outputW
,&unc_jp
[i
][1],destsz
)==0,"(%i) Strings do not match\n",i
);
1745 srcsz
= sjis_jp
[i
][0];
1746 hr
= pConvertINetMultiByteToUnicode(NULL
, 50932, &sjis_jp
[i
][1], &srcsz
, outputW
, &destsz
);
1747 ok(hr
== S_OK
,"(%i) Expected S_OK, got %08x\n",i
,hr
);
1748 ok(destsz
== unc_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[i
][0],destsz
);
1749 ok(srcsz
== sjis_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,sjis_jp
[i
][0],srcsz
);
1750 ok(memcmp(outputW
,&unc_jp
[i
][1],destsz
)==0,"(%i) Strings do not match\n",i
);
1753 static void test_GetScriptFontInfo(IMLangFontLink2
*font_link
)
1757 SCRIPTFONTINFO sfi
[1];
1760 hr
= IMLangFontLink2_GetScriptFontInfo(font_link
, sidAsciiLatin
, 0, &nfonts
, NULL
);
1761 ok(hr
== S_OK
, "GetScriptFontInfo failed %u\n", GetLastError());
1762 ok(nfonts
, "unexpected result\n");
1765 hr
= IMLangFontLink2_GetScriptFontInfo(font_link
, sidAsciiLatin
, SCRIPTCONTF_FIXED_FONT
, &nfonts
, NULL
);
1766 ok(hr
== S_OK
, "GetScriptFontInfo failed %u\n", GetLastError());
1767 ok(nfonts
, "unexpected result\n");
1770 hr
= IMLangFontLink2_GetScriptFontInfo(font_link
, sidAsciiLatin
, SCRIPTCONTF_PROPORTIONAL_FONT
, &nfonts
, NULL
);
1771 ok(hr
== S_OK
, "GetScriptFontInfo failed %u\n", GetLastError());
1772 ok(nfonts
, "unexpected result\n");
1775 memset(sfi
, 0, sizeof(sfi
));
1776 hr
= IMLangFontLink2_GetScriptFontInfo(font_link
, sidAsciiLatin
, SCRIPTCONTF_FIXED_FONT
, &nfonts
, sfi
);
1777 ok(hr
== S_OK
, "GetScriptFontInfo failed %u\n", GetLastError());
1778 ok(nfonts
== 1, "got %u, expected 1\n", nfonts
);
1779 ok(sfi
[0].scripts
!= 0, "unexpected result\n");
1780 ok(sfi
[0].wszFont
[0], "unexpected result\n");
1783 memset(sfi
, 0, sizeof(sfi
));
1784 hr
= IMLangFontLink2_GetScriptFontInfo(font_link
, sidAsciiLatin
, SCRIPTCONTF_PROPORTIONAL_FONT
, &nfonts
, sfi
);
1785 ok(hr
== S_OK
, "GetScriptFontInfo failed %u\n", GetLastError());
1786 ok(nfonts
== 1, "got %u, expected 1\n", nfonts
);
1787 ok(sfi
[0].scripts
!= 0, "unexpected result\n");
1788 ok(sfi
[0].wszFont
[0], "unexpected result\n");
1791 static void test_CodePageToScriptID(IMLangFontLink2
*font_link
)
1809 {1250, sidAsciiLatin
},
1810 {1251, sidCyrillic
},
1811 {1252, sidAsciiLatin
},
1813 {1254, sidAsciiLatin
},
1816 {1257, sidAsciiLatin
},
1817 {1258, sidAsciiLatin
},
1818 {CP_UNICODE
, 0, E_FAIL
}
1821 for (i
= 0; i
< sizeof(cp_sid
)/sizeof(cp_sid
[0]); i
++)
1823 hr
= IMLangFontLink2_CodePageToScriptID(font_link
, cp_sid
[i
].cp
, &sid
);
1824 ok(hr
== cp_sid
[i
].hr
, "%u CodePageToScriptID failed 0x%08x %u\n", i
, hr
, GetLastError());
1827 ok(sid
== cp_sid
[i
].sid
,
1828 "%u got sid %u for codepage %u, expected %u\n", i
, sid
, cp_sid
[i
].cp
, cp_sid
[i
].sid
);
1833 static void test_GetFontUnicodeRanges(IMLangFontLink2
*font_link
)
1837 HFONT hfont
, old_hfont
;
1842 hdc
= CreateCompatibleDC(0);
1843 memset(&lf
, 0, sizeof(lf
));
1844 lstrcpyA(lf
.lfFaceName
, "Arial");
1845 hfont
= CreateFontIndirectA(&lf
);
1846 old_hfont
= SelectObject(hdc
, hfont
);
1849 hr
= IMLangFontLink2_GetFontUnicodeRanges(font_link
, NULL
, &count
, NULL
);
1850 ok(hr
== E_FAIL
, "expected E_FAIL, got 0x%08x\n", hr
);
1852 hr
= IMLangFontLink2_GetFontUnicodeRanges(font_link
, hdc
, NULL
, NULL
);
1853 ok(hr
== E_INVALIDARG
, "expected E_FAIL, got 0x%08x\n", hr
);
1856 hr
= IMLangFontLink2_GetFontUnicodeRanges(font_link
, hdc
, &count
, NULL
);
1857 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
1858 ok(count
, "expected count > 0\n");
1860 ur
= HeapAlloc(GetProcessHeap(), 0, sizeof(*ur
) * count
);
1862 hr
= IMLangFontLink2_GetFontUnicodeRanges(font_link
, hdc
, &count
, ur
);
1863 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
1866 hr
= IMLangFontLink2_GetFontUnicodeRanges(font_link
, hdc
, &count
, ur
);
1867 ok(hr
== S_OK
, "expected S_OK, got 0x%08x\n", hr
);
1869 HeapFree(GetProcessHeap(), 0, ur
);
1871 SelectObject(hdc
, old_hfont
);
1872 DeleteObject(hfont
);
1876 static void test_IsCodePageInstallable(IMultiLanguage2
*ml2
)
1881 for (i
= 0; i
< 0xffff; i
++)
1883 hr
= IMultiLanguage2_IsCodePageInstallable(ml2
, i
);
1885 /* it would be better to use IMultiLanguage2_ValidateCodePageEx here but that brings
1886 * up an installation dialog on some platforms, even when specifying CPIOD_PEEK.
1888 if (IsValidCodePage(i
))
1890 broken(hr
== S_FALSE
) || /* win2k */
1891 broken(hr
== E_INVALIDARG
), /* win2k */
1892 "code page %u is valid but not installable 0x%08x\n", i
, hr
);
1896 static void test_GetGlobalFontLinkObject(void)
1901 ret
= GetGlobalFontLinkObject(NULL
);
1902 ok(ret
== E_INVALIDARG
, "expected E_INVALIDARG got %#x\n", ret
);
1904 unknown
= (void *)0xdeadbeef;
1905 ret
= GetGlobalFontLinkObject(&unknown
);
1907 ok(ret
== S_OK
, "expected S_OK got %#x\n", ret
);
1908 ok(unknown
!= NULL
&& unknown
!= (void *)0xdeadbeef,
1909 "GetGlobalFontLinkObject() returned %p\n", unknown
);
1915 IMultiLanguage
*iML
= NULL
;
1916 IMultiLanguage2
*iML2
= NULL
;
1917 IMLangFontLink
*iMLFL
= NULL
;
1918 IMLangFontLink2
*iMLFL2
= NULL
;
1921 if (!init_function_ptrs())
1925 test_Rfc1766ToLcid();
1926 test_LcidToRfc1766();
1928 test_ConvertINetUnicodeToMultiByte();
1929 test_JapaneseConversion();
1931 test_GetGlobalFontLinkObject();
1933 trace("IMultiLanguage\n");
1934 ret
= CoCreateInstance(&CLSID_CMultiLanguage
, NULL
, CLSCTX_INPROC_SERVER
,
1935 &IID_IMultiLanguage
, (void **)&iML
);
1936 if (ret
!= S_OK
|| !iML
) return;
1938 test_GetNumberOfCodePageInfo((IMultiLanguage2
*)iML
);
1939 IMultiLanguage_Release(iML
);
1942 /* IMultiLanguage2 (IE5.0 and above) */
1943 trace("IMultiLanguage2\n");
1944 ret
= CoCreateInstance(&CLSID_CMultiLanguage
, NULL
, CLSCTX_INPROC_SERVER
,
1945 &IID_IMultiLanguage2
, (void **)&iML2
);
1946 if (ret
!= S_OK
|| !iML2
) return;
1949 test_GetLcidFromRfc1766(iML2
);
1950 test_GetRfc1766FromLcid(iML2
);
1951 test_GetRfc1766Info(iML2
);
1952 test_GetNumberOfCodePageInfo(iML2
);
1954 test_EnumCodePages(iML2
, 0);
1955 test_EnumCodePages(iML2
, MIMECONTF_MIME_LATEST
);
1956 test_EnumCodePages(iML2
, MIMECONTF_BROWSER
);
1957 test_EnumCodePages(iML2
, MIMECONTF_MINIMAL
);
1958 test_EnumCodePages(iML2
, MIMECONTF_VALID
);
1959 /* FIXME: why MIMECONTF_MIME_REGISTRY returns 0 of supported codepages? */
1960 /*test_EnumCodePages(iML2, MIMECONTF_MIME_REGISTRY);*/
1962 test_EnumScripts(iML2
, 0);
1963 test_EnumScripts(iML2
, SCRIPTCONTF_SCRIPT_USER
);
1964 test_EnumScripts(iML2
, SCRIPTCONTF_SCRIPT_USER
| SCRIPTCONTF_SCRIPT_HIDE
| SCRIPTCONTF_SCRIPT_SYSTEM
);
1966 ret
= IMultiLanguage2_IsConvertible(iML2
, CP_UTF8
, CP_UNICODE
);
1967 ok(ret
== S_OK
, "IMultiLanguage2_IsConvertible(CP_UTF8 -> CP_UNICODE) = %08x\n", ret
);
1968 ret
= IMultiLanguage2_IsConvertible(iML2
, CP_UNICODE
, CP_UTF8
);
1969 ok(ret
== S_OK
, "IMultiLanguage2_IsConvertible(CP_UNICODE -> CP_UTF8) = %08x\n", ret
);
1971 test_multibyte_to_unicode_translations(iML2
);
1972 test_IMultiLanguage2_ConvertStringFromUnicode(iML2
);
1974 test_IsCodePageInstallable(iML2
);
1976 IMultiLanguage2_Release(iML2
);
1979 /* IMLangFontLink */
1980 ret
= CoCreateInstance(&CLSID_CMultiLanguage
, NULL
, CLSCTX_INPROC_SERVER
,
1981 &IID_IMLangFontLink
, (void **)&iMLFL
);
1982 if (ret
!= S_OK
|| !iMLFL
) return;
1984 IMLangFontLink_Test(iMLFL
);
1985 IMLangFontLink_Release(iMLFL
);
1987 /* IMLangFontLink2 */
1988 ret
= CoCreateInstance(&CLSID_CMultiLanguage
, NULL
, CLSCTX_INPROC_SERVER
,
1989 &IID_IMLangFontLink2
, (void **)&iMLFL2
);
1990 if (ret
!= S_OK
|| !iMLFL2
) return;
1992 test_GetScriptFontInfo(iMLFL2
);
1993 test_GetFontUnicodeRanges(iMLFL2
);
1994 test_CodePageToScriptID(iMLFL2
);
1995 IMLangFontLink2_Release(iMLFL2
);