user32/tests: Fix the listbox delete test on NT4.
[wine] / dlls / mlang / tests / mlang.c
1 /*
2  * Unit test suite for MLANG APIs.
3  *
4  * Copyright 2004 Dmitry Timoshkov
5  * Copyright 2009 Detlef Riekenberg
6  *
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.
11  *
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.
16  *
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
20  */
21
22 #define COBJMACROS
23
24 #include <stdarg.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winerror.h"
29 #include "initguid.h"
30 #include "mlang.h"
31
32 #include "wine/test.h"
33
34 #ifndef CP_UNICODE
35 #define CP_UNICODE 1200
36 #endif
37
38 #if 0
39 #define DUMP_CP_INFO
40 #define DUMP_SCRIPT_INFO
41
42 #if defined DUMP_CP_INFO || defined DUMP_SCRIPT_INFO
43 #include "wine/debug.h"
44 #endif
45 #endif /* 0 */
46
47 static BOOL (WINAPI *pGetCPInfoExA)(UINT, DWORD, LPCPINFOEXA);
48 static HRESULT (WINAPI *pConvertINetMultiByteToUnicode)(LPDWORD, DWORD, LPCSTR,
49                                                         LPINT, LPWSTR, LPINT);
50 static HRESULT (WINAPI *pConvertINetUnicodeToMultiByte)(LPDWORD, DWORD, LPCWSTR,
51                                                         LPINT, LPSTR, LPINT);
52 typedef struct lcid_tag_table {
53     LPCSTR rfc1766;
54     LCID lcid;
55     HRESULT hr;
56 } lcid_table_entry;
57
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 to small for the country */
61
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},
67
68     {"ar",    1,        S_OK},
69     {"zh",    4,        S_OK},
70
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},
76
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},
83
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},
90
91     {"it",    0x0410,   S_OK},
92     {"it-ch", 0x0810,   S_OK},
93
94     {"nl",    0x0413,   S_OK},
95     {"nl-be", 0x0813,   S_OK},
96     {"pl",    0x0415,   S_OK},
97     {"ru",    0x0419,   S_OK},
98
99     {"kok",   0x0457,   S_OK}
100
101 };
102
103
104 static BOOL init_function_ptrs(void)
105 {
106     HMODULE hMlang;
107
108     hMlang = LoadLibraryA("mlang.dll");
109     if (!hMlang)
110     {
111         skip("mlang not available\n");
112         return FALSE;
113     }
114
115     pConvertINetMultiByteToUnicode = (void *)GetProcAddress(hMlang, "ConvertINetMultiByteToUnicode");
116     pConvertINetUnicodeToMultiByte = (void *)GetProcAddress(hMlang, "ConvertINetUnicodeToMultiByte");
117
118     pGetCPInfoExA = (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetCPInfoExA");
119
120     return TRUE;
121 }
122
123 #define ok_w2(format, szString1, szString2) \
124 \
125     if (lstrcmpW((szString1), (szString2)) != 0) \
126     { \
127         CHAR string1[256], string2[256]; \
128         WideCharToMultiByte(CP_ACP, 0, (szString1), -1, string1, 256, NULL, NULL); \
129         WideCharToMultiByte(CP_ACP, 0, (szString2), -1, string2, 256, NULL, NULL); \
130         ok(0, (format), string1, string2); \
131     }
132
133 static void test_multibyte_to_unicode_translations(IMultiLanguage2 *iML2)
134 {
135     /* these APIs are broken regarding constness of the input buffer */
136     char stringA[] = "Just a test string\0"; /* double 0 for CP_UNICODE tests */
137     WCHAR stringW[] = {'J','u','s','t',' ','a',' ','t','e','s','t',' ','s','t','r','i','n','g',0};
138     char bufA[256];
139     WCHAR bufW[256];
140     UINT lenA, lenW, expected_len;
141     HRESULT ret;
142
143     /* IMultiLanguage2_ConvertStringToUnicode tests */
144
145     memset(bufW, 'x', sizeof(bufW));
146     lenA = 0;
147     lenW = sizeof(bufW)/sizeof(bufW[0]);
148     ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, 1252, stringA, &lenA, bufW, &lenW);
149     ok(ret == S_OK, "IMultiLanguage2_ConvertStringToUnicode failed: %08x\n", ret);
150     ok(lenA == 0, "expected lenA 0, got %u\n", lenA);
151     ok(lenW == 0, "expected lenW 0, got %u\n", lenW);
152
153     memset(bufW, 'x', sizeof(bufW));
154     lenA = -1;
155     lenW = sizeof(bufW)/sizeof(bufW[0]);
156     ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, 1252, stringA, &lenA, bufW, &lenW);
157     ok(ret == S_OK, "IMultiLanguage2_ConvertStringToUnicode failed: %08x\n", ret);
158     ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
159     ok(lenW == lstrlenW(stringW), "expected lenW %u, got %u\n", lstrlenW(stringW), lenW);
160     if (lenW < sizeof(bufW)/sizeof(bufW[0])) {
161        /* can only happen if the convert call fails */
162        ok(bufW[lenW] != 0, "buf should not be 0 terminated\n");
163        bufW[lenW] = 0; /* -1 doesn't include 0 terminator */
164     }
165     ok(!lstrcmpW(bufW, stringW), "bufW/stringW mismatch\n");
166
167     memset(bufW, 'x', sizeof(bufW));
168     lenA = -1;
169     lenW = 5;
170     ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, 1252, stringA, &lenA, bufW, &lenW);
171     ok(ret == E_FAIL, "IMultiLanguage2_ConvertStringToUnicode should fail: %08x\n", ret);
172     ok(lenW == 0, "expected lenW 0, got %u\n", lenW);
173     /* still has to do partial conversion */
174     ok(!memcmp(bufW, stringW, 5 * sizeof(WCHAR)), "bufW/stringW mismatch\n");
175
176     memset(bufW, 'x', sizeof(bufW));
177     lenA = -1;
178     lenW = sizeof(bufW)/sizeof(bufW[0]);
179     ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, CP_UNICODE, stringA, &lenA, bufW, &lenW);
180     ok(ret == S_OK, "IMultiLanguage2_ConvertStringToUnicode failed: %08x\n", ret);
181     ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
182     ok(lenW == lstrlenW(stringW)/(int)sizeof(WCHAR), "wrong lenW %u\n", lenW);
183     ok(bufW[lenW] != 0, "buf should not be 0 terminated\n");
184     bufW[lenW] = 0; /* -1 doesn't include 0 terminator */
185     ok(!lstrcmpA((LPCSTR)bufW, stringA), "bufW/stringA mismatch\n");
186
187     memset(bufW, 'x', sizeof(bufW));
188     lenA = lstrlenA(stringA);
189     lenW = 0;
190     ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, 1252, stringA, &lenA, NULL, &lenW);
191     ok(ret == S_OK, "IMultiLanguage2_ConvertStringToUnicode failed: %08x\n", ret);
192     ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
193     expected_len = MultiByteToWideChar(1252, 0, stringA, lenA, NULL, 0);
194     ok(lenW == expected_len, "expected lenW %u, got %u\n", expected_len, lenW);
195
196     memset(bufW, 'x', sizeof(bufW));
197     lenA = lstrlenA(stringA);
198     lenW = sizeof(bufW)/sizeof(bufW[0]);
199     ret = pConvertINetMultiByteToUnicode(NULL, 1252, stringA, (INT *)&lenA, NULL, (INT *)&lenW);
200     ok(ret == S_OK, "ConvertINetMultiByteToUnicode failed: %08x\n", ret);
201     ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
202     expected_len = MultiByteToWideChar(1252, 0, stringA, lenA, NULL, 0);
203     ok(lenW == expected_len, "expected lenW %u, got %u\n", expected_len, lenW);
204
205     memset(bufW, 'x', sizeof(bufW));
206     lenA = lstrlenA(stringA);
207     lenW = 0;
208     ret = pConvertINetMultiByteToUnicode(NULL, 1252, stringA, (INT *)&lenA, NULL, (INT *)&lenW);
209     ok(ret == S_OK, "ConvertINetMultiByteToUnicode failed: %08x\n", ret);
210     ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
211     expected_len = MultiByteToWideChar(1252, 0, stringA, lenA, NULL, 0);
212     ok(lenW == expected_len, "expected lenW %u, got %u\n", expected_len, lenW);
213
214     /* IMultiLanguage2_ConvertStringFromUnicode tests */
215
216     memset(bufA, 'x', sizeof(bufA));
217     lenW = 0;
218     lenA = sizeof(bufA);
219     ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, stringW, &lenW, bufA, &lenA);
220     ok(ret == S_OK, "IMultiLanguage2_ConvertStringFromUnicode failed: %08x\n", ret);
221     ok(lenA == 0, "expected lenA 0, got %u\n", lenA);
222     ok(lenW == 0, "expected lenW 0, got %u\n", lenW);
223
224     memset(bufA, 'x', sizeof(bufA));
225     lenW = -1;
226     lenA = sizeof(bufA);
227     ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, stringW, &lenW, bufA, &lenA);
228     ok(ret == S_OK, "IMultiLanguage2_ConvertStringFromUnicode failed: %08x\n", ret);
229     ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
230     ok(lenW == lstrlenW(stringW), "expected lenW %u, got %u\n", lstrlenW(stringW), lenW);
231     ok(bufA[lenA] != 0, "buf should not be 0 terminated\n");
232     bufA[lenA] = 0; /* -1 doesn't include 0 terminator */
233     ok(!lstrcmpA(bufA, stringA), "bufA/stringA mismatch\n");
234
235     memset(bufA, 'x', sizeof(bufA));
236     lenW = -1;
237     lenA = 5;
238     ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, stringW, &lenW, bufA, &lenA);
239     ok(ret == E_FAIL, "IMultiLanguage2_ConvertStringFromUnicode should fail: %08x\n", ret);
240     ok(lenA == 0, "expected lenA 0, got %u\n", lenA);
241     /* still has to do partial conversion */
242     ok(!memcmp(bufA, stringA, 5), "bufW/stringW mismatch\n");
243
244     memset(bufA, 'x', sizeof(bufA));
245     lenW = -1;
246     lenA = sizeof(bufA);
247     ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, CP_UNICODE, stringW, &lenW, bufA, &lenA);
248     ok(ret == S_OK, "IMultiLanguage2_ConvertStringFromUnicode failed: %08x\n", ret);
249     ok(lenA == lstrlenA(stringA) * (int)sizeof(WCHAR), "wrong lenA %u\n", lenA);
250     ok(lenW == lstrlenW(stringW), "expected lenW %u, got %u\n", lstrlenW(stringW), lenW);
251     ok(bufA[lenA] != 0 && bufA[lenA+1] != 0, "buf should not be 0 terminated\n");
252     bufA[lenA] = 0; /* -1 doesn't include 0 terminator */
253     bufA[lenA+1] = 0; /* sizeof(WCHAR) */
254     ok(!lstrcmpW((LPCWSTR)bufA, stringW), "bufA/stringW mismatch\n");
255
256     memset(bufA, 'x', sizeof(bufA));
257     lenW = lstrlenW(stringW);
258     lenA = 0;
259     ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, stringW, &lenW, NULL, &lenA);
260     ok(ret == S_OK, "IMultiLanguage2_ConvertStringFromUnicode failed: %08x\n", ret);
261     ok(lenW == lstrlenW(stringW), "expected lenW %u, got %u\n", lstrlenW(stringW), lenW);
262     expected_len = WideCharToMultiByte(1252, 0, stringW, lenW, NULL, 0, NULL, NULL);
263     ok(lenA == expected_len, "expected lenA %u, got %u\n", expected_len, lenA);
264 }
265
266 static void cpinfo_cmp(MIMECPINFO *cpinfo1, MIMECPINFO *cpinfo2)
267 {
268     ok(cpinfo1->dwFlags == cpinfo2->dwFlags, "dwFlags mismatch: %08x != %08x\n", cpinfo1->dwFlags, cpinfo2->dwFlags);
269     ok(cpinfo1->uiCodePage == cpinfo2->uiCodePage, "uiCodePage mismatch: %u != %u\n", cpinfo1->uiCodePage, cpinfo2->uiCodePage);
270     ok(cpinfo1->uiFamilyCodePage == cpinfo2->uiFamilyCodePage, "uiFamilyCodePage mismatch: %u != %u\n", cpinfo1->uiFamilyCodePage, cpinfo2->uiFamilyCodePage);
271     ok(!lstrcmpW(cpinfo1->wszDescription, cpinfo2->wszDescription), "wszDescription mismatch\n");
272     ok(!lstrcmpW(cpinfo1->wszWebCharset, cpinfo2->wszWebCharset), "wszWebCharset mismatch\n");
273     ok(!lstrcmpW(cpinfo1->wszHeaderCharset, cpinfo2->wszHeaderCharset), "wszHeaderCharset mismatch\n");
274     ok(!lstrcmpW(cpinfo1->wszBodyCharset, cpinfo2->wszBodyCharset), "wszBodyCharset mismatch\n");
275     ok(!lstrcmpW(cpinfo1->wszFixedWidthFont, cpinfo2->wszFixedWidthFont), "wszFixedWidthFont mismatch\n");
276     ok(!lstrcmpW(cpinfo1->wszProportionalFont, cpinfo2->wszProportionalFont), "wszProportionalFont mismatch\n");
277     ok(cpinfo1->bGDICharset == cpinfo2->bGDICharset, "bGDICharset mismatch: %d != %d\n", cpinfo1->bGDICharset, cpinfo2->bGDICharset);
278 }
279
280 #ifdef DUMP_CP_INFO
281 static const char *dump_mime_flags(DWORD flags)
282 {
283     static char buf[1024];
284
285     buf[0] = 0;
286
287     if (flags & MIMECONTF_MAILNEWS) strcat(buf, " MIMECONTF_MAILNEWS");
288     if (flags & MIMECONTF_BROWSER) strcat(buf, " MIMECONTF_BROWSER");
289     if (flags & MIMECONTF_MINIMAL) strcat(buf, " MIMECONTF_MINIMAL");
290     if (flags & MIMECONTF_IMPORT) strcat(buf, " MIMECONTF_IMPORT");
291     if (flags & MIMECONTF_SAVABLE_MAILNEWS) strcat(buf, " MIMECONTF_SAVABLE_MAILNEWS");
292     if (flags & MIMECONTF_SAVABLE_BROWSER) strcat(buf, " MIMECONTF_SAVABLE_BROWSER");
293     if (flags & MIMECONTF_EXPORT) strcat(buf, " MIMECONTF_EXPORT");
294     if (flags & MIMECONTF_PRIVCONVERTER) strcat(buf, " MIMECONTF_PRIVCONVERTER");
295     if (flags & MIMECONTF_VALID) strcat(buf, " MIMECONTF_VALID");
296     if (flags & MIMECONTF_VALID_NLS) strcat(buf, " MIMECONTF_VALID_NLS");
297     if (flags & MIMECONTF_MIME_IE4) strcat(buf, " MIMECONTF_MIME_IE4");
298     if (flags & MIMECONTF_MIME_LATEST) strcat(buf, " MIMECONTF_MIME_LATEST");
299     if (flags & MIMECONTF_MIME_REGISTRY) strcat(buf, " MIMECONTF_MIME_REGISTRY");
300
301     return buf;
302 }
303 #endif
304
305 static HRESULT check_convertible(IMultiLanguage2 *iML2, UINT from, UINT to)
306 {
307     CHAR convert[MAX_PATH];
308     BYTE dest[MAX_PATH];
309     HRESULT hr;
310     UINT srcsz, destsz;
311
312     static WCHAR strW[] = {'a','b','c',0};
313
314     /* Check to see if the target codepage has these characters or not */
315     if (from != CP_UTF8)
316     {
317         BOOL fDefaultChar;
318         char ch[10];
319         int cb;
320         cb = WideCharToMultiByte( from, WC_NO_BEST_FIT_CHARS | WC_COMPOSITECHECK | WC_DEFAULTCHAR,
321                                   strW, 3, ch, sizeof(ch), NULL, &fDefaultChar);
322
323         if(cb == 0 || fDefaultChar)
324         {
325             trace("target codepage %i does not contain 'abc'\n",from);
326             return E_FAIL;
327         }
328     }
329
330     srcsz = lstrlenW(strW) + 1;
331     destsz = MAX_PATH;
332     hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, from, strW,
333                                                   &srcsz, convert, &destsz);
334     if (hr != S_OK)
335         return S_FALSE;
336
337     srcsz = -1;
338     destsz = MAX_PATH;
339     hr = IMultiLanguage2_ConvertString(iML2, NULL, from, to, (BYTE *)convert,
340                                        &srcsz, dest, &destsz);
341     if (hr != S_OK)
342         return S_FALSE;
343
344     return S_OK;
345 }
346
347 static void test_EnumCodePages(IMultiLanguage2 *iML2, DWORD flags)
348 {
349     IEnumCodePage *iEnumCP = NULL;
350     MIMECPINFO *cpinfo;
351     MIMECPINFO cpinfo2;
352     HRESULT ret;
353     ULONG i, n;
354     UINT total;
355
356     total = 0;
357     ret = IMultiLanguage2_GetNumberOfCodePageInfo(iML2, &total);
358     ok(ret == S_OK && total != 0, "IMultiLanguage2_GetNumberOfCodePageInfo: expected S_OK/!0, got %08x/%u\n", ret, total);
359
360     trace("total mlang supported codepages %u\n", total);
361
362     ret = IMultiLanguage2_EnumCodePages(iML2, flags, LANG_NEUTRAL, &iEnumCP);
363     ok(ret == S_OK && iEnumCP, "IMultiLanguage2_EnumCodePages: expected S_OK/!NULL, got %08x/%p\n", ret, iEnumCP);
364
365     ret = IEnumCodePage_Reset(iEnumCP);
366     ok(ret == S_OK, "IEnumCodePage_Reset: expected S_OK, got %08x\n", ret);
367     n = 65536;
368     ret = IEnumCodePage_Next(iEnumCP, 0, NULL, &n);
369     if (ret == S_FALSE)
370         ok(n == 0 && ret == S_FALSE, "IEnumCodePage_Next: expected 0/S_FALSE, got %u/%08x\n", n, ret);
371     else if (ret == E_FAIL)
372         ok(n == 65536 && ret == E_FAIL, "IEnumCodePage_Next: expected 65536/E_FAIL, got %u/%08x\n", n, ret);
373     ret = IEnumCodePage_Next(iEnumCP, 0, NULL, NULL);
374     if (ret == S_FALSE)
375         ok(ret == S_FALSE, "IEnumCodePage_Next: expected S_FALSE, got %08x\n", ret);
376     else if (ret == E_FAIL)
377         ok(n == 65536 && ret == E_FAIL, "IEnumCodePage_Next: expected 65536/E_FAIL, got %u/%08x\n", n, ret);
378
379     cpinfo = HeapAlloc(GetProcessHeap(), 0, sizeof(*cpinfo) * total * 2);
380
381     n = total * 2;
382     ret = IEnumCodePage_Next(iEnumCP, 0, cpinfo, &n);
383     ok(ret == S_FALSE && n == 0, "IEnumCodePage_Next: expected S_FALSE/0, got %08x/%u\n", ret, n);
384
385     n = total * 2;
386     ret = IEnumCodePage_Next(iEnumCP, n, cpinfo, &n);
387     ok(ret == S_OK && n != 0, "IEnumCodePage_Next: expected S_OK/!0, got %08x/%u\n", ret, n);
388
389     trace("flags %08x, enumerated codepages %u\n", flags, n);
390
391     if (!flags)
392     {
393         ok(n == total, "IEnumCodePage_Next: expected %u, got %u\n", total, n);
394
395         flags = MIMECONTF_MIME_LATEST;
396     }
397
398     total = n;
399
400     for (i = 0; i < n; i++)
401     {
402         CHARSETINFO csi;
403         MIMECSETINFO mcsi;
404         HRESULT convertible = S_OK;
405         static const WCHAR autoW[] = {'_','a','u','t','o',0};
406         static const WCHAR feffW[] = {'u','n','i','c','o','d','e','F','E','F','F',0};
407
408 #ifdef DUMP_CP_INFO
409         trace("MIMECPINFO #%u:\n"
410               "dwFlags %08x %s\n"
411               "uiCodePage %u\n"
412               "uiFamilyCodePage %u\n"
413               "wszDescription %s\n"
414               "wszWebCharset %s\n"
415               "wszHeaderCharset %s\n"
416               "wszBodyCharset %s\n"
417               "wszFixedWidthFont %s\n"
418               "wszProportionalFont %s\n"
419               "bGDICharset %d\n\n",
420               i,
421               cpinfo[i].dwFlags, dump_mime_flags(cpinfo[i].dwFlags),
422               cpinfo[i].uiCodePage,
423               cpinfo[i].uiFamilyCodePage,
424               wine_dbgstr_w(cpinfo[i].wszDescription),
425               wine_dbgstr_w(cpinfo[i].wszWebCharset),
426               wine_dbgstr_w(cpinfo[i].wszHeaderCharset),
427               wine_dbgstr_w(cpinfo[i].wszBodyCharset),
428               wine_dbgstr_w(cpinfo[i].wszFixedWidthFont),
429               wine_dbgstr_w(cpinfo[i].wszProportionalFont),
430               cpinfo[i].bGDICharset);
431 #endif
432         ok(cpinfo[i].dwFlags & flags, "enumerated flags %08x do not include requested %08x\n", cpinfo[i].dwFlags, flags);
433
434         if (TranslateCharsetInfo((DWORD *)(INT_PTR)cpinfo[i].uiFamilyCodePage, &csi, TCI_SRCCODEPAGE))
435             ok(cpinfo[i].bGDICharset == csi.ciCharset, "%d != %d\n", cpinfo[i].bGDICharset, csi.ciCharset);
436         else
437             if (winetest_debug > 1)
438                 trace("TranslateCharsetInfo failed for cp %u\n", cpinfo[i].uiFamilyCodePage);
439
440 #ifdef DUMP_CP_INFO
441         trace("%u: codepage %u family %u\n", i, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
442 #endif
443         /* Win95 does not support UTF-7 */
444         if (cpinfo[i].uiCodePage == CP_UTF7) continue;
445
446         /* support files for some codepages might be not installed, or
447          * the codepage is just an alias.
448          */
449         if (IsValidCodePage(cpinfo[i].uiCodePage))
450         {
451             ret = IMultiLanguage2_IsConvertible(iML2, cpinfo[i].uiCodePage, CP_UNICODE);
452             ok(ret == S_OK, "IMultiLanguage2_IsConvertible(%u -> CP_UNICODE) = %08x\n", cpinfo[i].uiCodePage, ret);
453             ret = IMultiLanguage2_IsConvertible(iML2, CP_UNICODE, cpinfo[i].uiCodePage);
454             ok(ret == S_OK, "IMultiLanguage2_IsConvertible(CP_UNICODE -> %u) = %08x\n", cpinfo[i].uiCodePage, ret);
455
456             convertible = check_convertible(iML2, cpinfo[i].uiCodePage, CP_UTF8);
457             if (convertible != E_FAIL)
458             {
459                 ret = IMultiLanguage2_IsConvertible(iML2, cpinfo[i].uiCodePage, CP_UTF8);
460                 ok(ret == convertible, "IMultiLanguage2_IsConvertible(%u -> CP_UTF8) = %08x\n", cpinfo[i].uiCodePage, ret);
461                 ret = IMultiLanguage2_IsConvertible(iML2, CP_UTF8, cpinfo[i].uiCodePage);
462                 ok(ret == convertible, "IMultiLanguage2_IsConvertible(CP_UTF8 -> %u) = %08x\n", cpinfo[i].uiCodePage, ret);
463             }
464         }
465         else
466             if (winetest_debug > 1)
467                 trace("IsValidCodePage failed for cp %u\n", cpinfo[i].uiCodePage);
468
469     if (memcmp(cpinfo[i].wszWebCharset,feffW,sizeof(WCHAR)*11)==0)
470         skip("Legacy windows bug returning invalid charset of unicodeFEFF\n");
471     else
472     {
473         ret = IMultiLanguage2_GetCharsetInfo(iML2, cpinfo[i].wszWebCharset, &mcsi);
474         /* _autoxxx charsets are a fake and GetCharsetInfo fails for them */
475         if (memcmp(cpinfo[i].wszWebCharset, autoW, 5 * sizeof(WCHAR)))
476         {
477             ok (ret == S_OK, "IMultiLanguage2_GetCharsetInfo failed: %08x\n", ret);
478 #ifdef DUMP_CP_INFO
479             trace("%s: %u %u %s\n", wine_dbgstr_w(cpinfo[i].wszWebCharset), mcsi.uiCodePage, mcsi.uiInternetEncoding, wine_dbgstr_w(mcsi.wszCharset));
480 #endif
481             ok(!lstrcmpiW(cpinfo[i].wszWebCharset, mcsi.wszCharset),
482 #ifdef DUMP_CP_INFO
483                     "%s != %s\n",
484             wine_dbgstr_w(cpinfo[i].wszWebCharset), wine_dbgstr_w(mcsi.wszCharset));
485 #else
486                     "wszWebCharset mismatch\n");
487 #endif
488
489         if (0)
490         {
491             /* native mlang returns completely messed up encodings in some cases */
492             ok(mcsi.uiInternetEncoding == cpinfo[i].uiCodePage || mcsi.uiInternetEncoding == cpinfo[i].uiFamilyCodePage,
493             "%u != %u || %u\n", mcsi.uiInternetEncoding, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
494             ok(mcsi.uiCodePage == cpinfo[i].uiCodePage || mcsi.uiCodePage == cpinfo[i].uiFamilyCodePage,
495             "%u != %u || %u\n", mcsi.uiCodePage, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
496             }
497         }
498     }
499
500     if (memcmp(cpinfo[i].wszHeaderCharset,feffW,sizeof(WCHAR)*11)==0)
501         skip("Legacy windows bug returning invalid charset of unicodeFEFF\n");
502     else
503     {
504         ret = IMultiLanguage2_GetCharsetInfo(iML2, cpinfo[i].wszHeaderCharset, &mcsi);
505         /* _autoxxx charsets are a fake and GetCharsetInfo fails for them */
506         if (memcmp(cpinfo[i].wszHeaderCharset, autoW, 5 * sizeof(WCHAR)))
507         {
508             ok (ret == S_OK, "IMultiLanguage2_GetCharsetInfo failed: %08x\n", ret);
509 #ifdef DUMP_CP_INFO
510             trace("%s: %u %u %s\n", wine_dbgstr_w(cpinfo[i].wszHeaderCharset), mcsi.uiCodePage, mcsi.uiInternetEncoding, wine_dbgstr_w(mcsi.wszCharset));
511 #endif
512             ok(!lstrcmpiW(cpinfo[i].wszHeaderCharset, mcsi.wszCharset),
513 #ifdef DUMP_CP_INFO
514                     "%s != %s\n",
515             wine_dbgstr_w(cpinfo[i].wszHeaderCharset), wine_dbgstr_w(mcsi.wszCharset));
516 #else
517                     "wszHeaderCharset mismatch\n");
518 #endif
519
520         if (0)
521         {
522             /* native mlang returns completely messed up encodings in some cases */
523             ok(mcsi.uiInternetEncoding == cpinfo[i].uiCodePage || mcsi.uiInternetEncoding == cpinfo[i].uiFamilyCodePage,
524             "%u != %u || %u\n", mcsi.uiInternetEncoding, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
525             ok(mcsi.uiCodePage == cpinfo[i].uiCodePage || mcsi.uiCodePage == cpinfo[i].uiFamilyCodePage,
526             "%u != %u || %u\n", mcsi.uiCodePage, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
527         }
528         }
529     }
530
531     if (memcmp(cpinfo[i].wszBodyCharset,feffW,sizeof(WCHAR)*11)==0)
532         skip("Legacy windows bug returning invalid charset of unicodeFEFF\n");
533     else
534     {
535         ret = IMultiLanguage2_GetCharsetInfo(iML2, cpinfo[i].wszBodyCharset, &mcsi);
536         /* _autoxxx charsets are a fake and GetCharsetInfo fails for them */
537         if (memcmp(cpinfo[i].wszBodyCharset, autoW, 5 * sizeof(WCHAR)))
538         {
539             ok (ret == S_OK, "IMultiLanguage2_GetCharsetInfo failed: %08x\n", ret);
540 #ifdef DUMP_CP_INFO
541             trace("%s: %u %u %s\n", wine_dbgstr_w(cpinfo[i].wszBodyCharset), mcsi.uiCodePage, mcsi.uiInternetEncoding, wine_dbgstr_w(mcsi.wszCharset));
542 #endif
543             ok(!lstrcmpiW(cpinfo[i].wszBodyCharset, mcsi.wszCharset),
544 #ifdef DUMP_CP_INFO
545                     "%s != %s\n",
546             wine_dbgstr_w(cpinfo[i].wszBodyCharset), wine_dbgstr_w(mcsi.wszCharset));
547 #else
548                     "wszBodyCharset mismatch\n");
549 #endif
550
551         if (0)
552         {
553             /* native mlang returns completely messed up encodings in some cases */
554             ok(mcsi.uiInternetEncoding == cpinfo[i].uiCodePage || mcsi.uiInternetEncoding == cpinfo[i].uiFamilyCodePage,
555             "%u != %u || %u\n", mcsi.uiInternetEncoding, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
556             ok(mcsi.uiCodePage == cpinfo[i].uiCodePage || mcsi.uiCodePage == cpinfo[i].uiFamilyCodePage,
557             "%u != %u || %u\n", mcsi.uiCodePage, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
558         }
559         }
560     }
561     }
562
563     /* now IEnumCodePage_Next should fail, since pointer is at the end */
564     n = 1;
565     ret = IEnumCodePage_Next(iEnumCP, 1, &cpinfo2, &n);
566     ok(ret == S_FALSE && n == 0, "IEnumCodePage_Next: expected S_FALSE/0, got %08x/%u\n", ret, n);
567
568     ret = IEnumCodePage_Reset(iEnumCP);
569     ok(ret == S_OK, "IEnumCodePage_Reset: expected S_OK, got %08x\n", ret);
570     n = 0;
571     ret = IEnumCodePage_Next(iEnumCP, 1, &cpinfo2, &n);
572     ok(n == 1 && ret == S_OK, "IEnumCodePage_Next: expected 1/S_OK, got %u/%08x\n", n, ret);
573     cpinfo_cmp(&cpinfo[0], &cpinfo2);
574
575     if (0)
576     {
577     /* Due to a bug in MS' implementation of IEnumCodePage_Skip
578      * it's not used here.
579      */
580     ret = IEnumCodePage_Skip(iEnumCP, 1);
581     ok(ret == S_OK, "IEnumCodePage_Skip: expected S_OK, got %08x\n", ret);
582     }
583     for (i = 0; i < total - 1; i++)
584     {
585         n = 0;
586         ret = IEnumCodePage_Next(iEnumCP, 1, &cpinfo2, &n);
587         ok(n == 1 && ret == S_OK, "IEnumCodePage_Next: expected 1/S_OK, got %u/%08x\n", n, ret);
588         cpinfo_cmp(&cpinfo[i + 1], &cpinfo2);
589     }
590
591     HeapFree(GetProcessHeap(), 0, cpinfo);
592     IEnumCodePage_Release(iEnumCP);
593 }
594
595 static void scriptinfo_cmp(SCRIPTINFO *sinfo1, SCRIPTINFO *sinfo2)
596 {
597     ok(sinfo1->ScriptId == sinfo2->ScriptId, "ScriptId mismatch: %d != %d\n", sinfo1->ScriptId, sinfo2->ScriptId);
598     ok(sinfo1->uiCodePage == sinfo2->uiCodePage, "uiCodePage mismatch: %u != %u\n", sinfo1->uiCodePage, sinfo2->uiCodePage);
599     ok(!lstrcmpW(sinfo1->wszDescription, sinfo2->wszDescription), "wszDescription mismatch\n");
600     ok(!lstrcmpW(sinfo1->wszFixedWidthFont, sinfo2->wszFixedWidthFont), "wszFixedWidthFont mismatch\n");
601     ok(!lstrcmpW(sinfo1->wszProportionalFont, sinfo2->wszProportionalFont), "wszProportionalFont mismatch\n");
602 }
603
604 static void test_EnumScripts(IMultiLanguage2 *iML2, DWORD flags)
605 {
606     IEnumScript *iEnumScript = NULL;
607     SCRIPTINFO *sinfo;
608     SCRIPTINFO sinfo2;
609     HRESULT ret;
610     ULONG i, n;
611     UINT total;
612
613     total = 0;
614     ret = IMultiLanguage2_GetNumberOfScripts(iML2, &total);
615     ok(ret == S_OK && total != 0, "IMultiLanguage2_GetNumberOfScripts: expected S_OK/!0, got %08x/%u\n", ret, total);
616
617     trace("total mlang supported scripts %u\n", total);
618
619     ret = IMultiLanguage2_EnumScripts(iML2, flags, LANG_NEUTRAL, &iEnumScript);
620     ok(ret == S_OK && iEnumScript, "IMultiLanguage2_EnumScripts: expected S_OK/!NULL, got %08x/%p\n", ret, iEnumScript);
621
622     ret = IEnumScript_Reset(iEnumScript);
623     ok(ret == S_OK, "IEnumScript_Reset: expected S_OK, got %08x\n", ret);
624     n = 65536;
625     ret = IEnumScript_Next(iEnumScript, 0, NULL, &n);
626     ok(n == 65536 && ret == E_FAIL, "IEnumScript_Next: expected 65536/E_FAIL, got %u/%08x\n", n, ret);
627     ret = IEnumScript_Next(iEnumScript, 0, NULL, NULL);
628     ok(ret == E_FAIL, "IEnumScript_Next: expected E_FAIL, got %08x\n", ret);
629
630     sinfo = HeapAlloc(GetProcessHeap(), 0, sizeof(*sinfo) * total * 2);
631
632     n = total * 2;
633     ret = IEnumScript_Next(iEnumScript, 0, sinfo, &n);
634     ok(ret == S_FALSE && n == 0, "IEnumScript_Next: expected S_FALSE/0, got %08x/%u\n", ret, n);
635
636     n = total * 2;
637     ret = IEnumScript_Next(iEnumScript, n, sinfo, &n);
638     ok(ret == S_OK && n != 0, "IEnumScript_Next: expected S_OK, got %08x/%u\n", ret, n);
639
640     trace("flags %08x, enumerated scripts %u\n", flags, n);
641
642     if (!flags)
643     {
644         ok(n == total, "IEnumScript_Next: expected %u, got %u\n", total, n);
645         flags = SCRIPTCONTF_SCRIPT_USER | SCRIPTCONTF_SCRIPT_HIDE | SCRIPTCONTF_SCRIPT_SYSTEM;
646     }
647
648     total = n;
649
650     for (i = 0; pGetCPInfoExA && i < n; i++)
651     {
652 #ifdef DUMP_SCRIPT_INFO
653         trace("SCRIPTINFO #%u:\n"
654               "ScriptId %08x\n"
655               "uiCodePage %u\n"
656               "wszDescription %s\n"
657               "wszFixedWidthFont %s\n"
658               "wszProportionalFont %s\n\n",
659               i,
660               sinfo[i].ScriptId,
661               sinfo[i].uiCodePage,
662               wine_dbgstr_w(sinfo[i].wszDescription),
663               wine_dbgstr_w(sinfo[i].wszFixedWidthFont),
664               wine_dbgstr_w(sinfo[i].wszProportionalFont));
665         trace("%u codepage %u\n", i, sinfo[i].uiCodePage);
666 #endif
667     }
668
669     /* now IEnumScript_Next should fail, since pointer is at the end */
670     n = 1;
671     ret = IEnumScript_Next(iEnumScript, 1, &sinfo2, &n);
672     ok(ret == S_FALSE && n == 0, "IEnumScript_Next: expected S_FALSE/0, got %08x/%u\n", ret, n);
673
674     ret = IEnumScript_Reset(iEnumScript);
675     ok(ret == S_OK, "IEnumScript_Reset: expected S_OK, got %08x\n", ret);
676     n = 0;
677     ret = IEnumScript_Next(iEnumScript, 1, &sinfo2, &n);
678     ok(n == 1 && ret == S_OK, "IEnumScript_Next: expected 1/S_OK, got %u/%08x\n", n, ret);
679     scriptinfo_cmp(&sinfo[0], &sinfo2);
680
681     if (0)
682     {
683     /* Due to a bug in MS' implementation of IEnumScript_Skip
684      * it's not used here.
685      */
686     ret = IEnumScript_Skip(iEnumScript, 1);
687     ok(ret == S_OK, "IEnumScript_Skip: expected S_OK, got %08x\n", ret);
688     }
689     for (i = 0; i < total - 1; i++)
690     {
691         n = 0;
692         ret = IEnumScript_Next(iEnumScript, 1, &sinfo2, &n);
693         ok(n == 1 && ret == S_OK, "IEnumScript_Next: expected 1/S_OK, got %u/%08x\n", n, ret);
694         scriptinfo_cmp(&sinfo[i + 1], &sinfo2);
695     }
696
697     HeapFree(GetProcessHeap(), 0, sinfo);
698     IEnumScript_Release(iEnumScript);
699 }
700
701 static void IMLangFontLink_Test(IMLangFontLink* iMLFL)
702 {
703     DWORD dwCodePages, dwManyCodePages;
704     DWORD dwCmpCodePages;
705     UINT CodePage;
706     static const WCHAR str[3] = { 'd', 0x0436, 0xff90 };
707     LONG processed;
708     HRESULT ret;
709
710     dwCodePages = ~0u;
711     ret = IMLangFontLink_CodePageToCodePages(iMLFL, -1, &dwCodePages);
712     ok(ret == E_FAIL, "IMLangFontLink_CodePageToCodePages should fail: %x\n", ret);
713     ok(dwCodePages == 0, "expected 0, got %u\n", dwCodePages);
714
715     dwCodePages = 0;
716     ret = IMLangFontLink_CodePageToCodePages(iMLFL, 932, &dwCodePages);
717     ok(ret == S_OK, "IMLangFontLink_CodePageToCodePages error %x\n", ret);
718     ok(dwCodePages == FS_JISJAPAN, "expected FS_JISJAPAN, got %08x\n", dwCodePages);
719     CodePage = 0;
720     ret = IMLangFontLink_CodePagesToCodePage(iMLFL, dwCodePages, 1035, &CodePage);
721     ok(ret == S_OK, "IMLangFontLink_CodePagesToCodePage error %x\n", ret);
722     ok(CodePage == 932, "Incorrect CodePage Returned (%i)\n",CodePage);
723
724     dwManyCodePages = 0;
725     ret = IMLangFontLink_CodePageToCodePages(iMLFL, 1252, &dwManyCodePages);
726     ok(ret == S_OK, "IMLangFontLink_CodePageToCodePages error %x\n", ret);
727     ok(dwManyCodePages == FS_LATIN1, "expected FS_LATIN1, got %08x\n", dwManyCodePages);
728     dwCodePages = 0;
729     ret = IMLangFontLink_CodePageToCodePages(iMLFL, 1256, &dwCodePages);
730     ok(ret == S_OK, "IMLangFontLink_CodePageToCodePages error %x\n", ret);
731     ok(dwCodePages == FS_ARABIC, "expected FS_ARABIC, got %08x\n", dwCodePages);
732     dwManyCodePages |= dwCodePages;
733     ret = IMLangFontLink_CodePageToCodePages(iMLFL, 874, &dwCodePages);
734     ok(ret == S_OK, "IMLangFontLink_CodePageToCodePages error %x\n", ret);
735     ok(dwCodePages == FS_THAI, "expected FS_THAI, got %08x\n", dwCodePages);
736     dwManyCodePages |= dwCodePages;
737
738     ret = IMLangFontLink_CodePagesToCodePage(iMLFL, dwManyCodePages, 1256, &CodePage);
739     ok(ret == S_OK, "IMLangFontLink_CodePagesToCodePage error %x\n", ret);
740     ok(CodePage == 1256, "Incorrect CodePage Returned (%i)\n",CodePage);
741
742     ret = IMLangFontLink_CodePagesToCodePage(iMLFL, dwManyCodePages, 936, &CodePage);
743     ok(ret == S_OK, "IMLangFontLink_CodePagesToCodePage error %x\n", ret);
744     ok(CodePage == 1252, "Incorrect CodePage Returned (%i)\n",CodePage);
745
746     /* Tests for GetCharCodePages */
747
748     /* Latin 1 */
749     dwCmpCodePages = FS_LATIN1 | FS_LATIN2 | FS_CYRILLIC | FS_GREEK | FS_TURKISH
750         | FS_HEBREW | FS_ARABIC | FS_BALTIC | FS_VIETNAMESE | FS_THAI
751         | FS_JISJAPAN | FS_CHINESESIMP | FS_WANSUNG | FS_CHINESETRAD;
752     ret = IMLangFontLink_GetCharCodePages(iMLFL, 'd', &dwCodePages);
753     ok(ret == S_OK, "IMLangFontLink_GetCharCodePages error %x\n", ret);
754     ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
755
756     dwCodePages = 0;
757     processed = 0;
758     ret = IMLangFontLink_GetStrCodePages(iMLFL, &str[0], 1, 0, &dwCodePages, &processed);
759     ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %x\n", ret);
760     ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
761     ok(processed == 1, "expected 1, got %d\n", processed);
762
763     /* Cyrillic */
764     dwCmpCodePages = FS_CYRILLIC | FS_JISJAPAN | FS_CHINESESIMP | FS_WANSUNG;
765     ret = IMLangFontLink_GetCharCodePages(iMLFL, 0x0436, &dwCodePages);
766     ok(ret == S_OK, "IMLangFontLink_GetCharCodePages error %x\n", ret);
767     ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
768
769     dwCodePages = 0;
770     processed = 0;
771     ret = IMLangFontLink_GetStrCodePages(iMLFL, &str[1], 1, 0, &dwCodePages, &processed);
772     ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %x\n", ret);
773     ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
774     ok(processed == 1, "expected 1, got %d\n", processed);
775
776     /* Japanese */
777     dwCmpCodePages =  FS_JISJAPAN;
778     ret = IMLangFontLink_GetCharCodePages(iMLFL, 0xff90, &dwCodePages);
779     ok(ret == S_OK, "IMLangFontLink_GetCharCodePages error %x\n", ret);
780     ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
781
782     dwCodePages = 0;
783     processed = 0;
784     ret = IMLangFontLink_GetStrCodePages(iMLFL, &str[2], 1, 0, &dwCodePages, &processed);
785     ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %x\n", ret);
786     ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
787     ok(processed == 1, "expected 1, got %d\n", processed);
788
789     dwCmpCodePages = FS_CYRILLIC | FS_JISJAPAN | FS_CHINESESIMP | FS_WANSUNG;
790     dwCodePages = 0;
791     processed = 0;
792     ret = IMLangFontLink_GetStrCodePages(iMLFL, str, 2, 0, &dwCodePages, &processed);
793     ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %x\n", ret);
794     ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
795     ok(processed == 2, "expected 2, got %d\n", processed);
796
797     dwCmpCodePages = FS_JISJAPAN;
798     dwCodePages = 0;
799     processed = 0;
800     ret = IMLangFontLink_GetStrCodePages(iMLFL, str, 3, 0, &dwCodePages, &processed);
801     ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %x\n", ret);
802     ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
803     ok(processed == 3, "expected 3, got %d\n", processed);
804
805     dwCodePages = 0xffff;
806     processed = -1;
807     ret = IMLangFontLink_GetStrCodePages(iMLFL, &str[2], 1, 0, &dwCodePages, &processed);
808     ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %x\n", ret);
809     ok(dwCodePages == dwCmpCodePages, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
810     ok(processed == 1, "expected 0, got %d\n", processed);
811
812     ret = IMLangFontLink_GetStrCodePages(iMLFL, &str[2], 1, 0, NULL, NULL);
813     ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %x\n", ret);
814
815     dwCodePages = 0xffff;
816     processed = -1;
817     ret = IMLangFontLink_GetStrCodePages(iMLFL, str, -1, 0, &dwCodePages, &processed);
818     ok(ret == E_INVALIDARG, "IMLangFontLink_GetStrCodePages should fail: %x\n", ret);
819     ok(dwCodePages == 0, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
820     ok(processed == 0, "expected 0, got %d\n", processed);
821
822     dwCodePages = 0xffff;
823     processed = -1;
824     ret = IMLangFontLink_GetStrCodePages(iMLFL, NULL, 1, 0, &dwCodePages, &processed);
825     ok(ret == E_INVALIDARG, "IMLangFontLink_GetStrCodePages should fail: %x\n", ret);
826     ok(dwCodePages == 0, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
827     ok(processed == 0, "expected 0, got %d\n", processed);
828
829     dwCodePages = 0xffff;
830     processed = -1;
831     ret = IMLangFontLink_GetStrCodePages(iMLFL, str, 0, 0, &dwCodePages, &processed);
832     ok(ret == E_INVALIDARG, "IMLangFontLink_GetStrCodePages should fail: %x\n", ret);
833     ok(dwCodePages == 0, "expected %x, got %x\n", dwCmpCodePages, dwCodePages);
834     ok(processed == 0, "expected 0, got %d\n", processed);
835 }
836
837 /* copied from libs/wine/string.c */
838 static WCHAR *strstrW(const WCHAR *str, const WCHAR *sub)
839 {
840     while (*str)
841     {
842         const WCHAR *p1 = str, *p2 = sub;
843         while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; }
844         if (!*p2) return (WCHAR *)str;
845         str++;
846     }
847     return NULL;
848 }
849
850 static void test_rfc1766(IMultiLanguage2 *iML2)
851 {
852     IEnumRfc1766 *pEnumRfc1766;
853     RFC1766INFO info;
854     ULONG n;
855     HRESULT ret;
856     BSTR rfcstr;
857
858     ret = IMultiLanguage2_EnumRfc1766(iML2, LANG_NEUTRAL, &pEnumRfc1766);
859     ok(ret == S_OK, "IMultiLanguage2_EnumRfc1766 error %08x\n", ret);
860
861     while (1)
862     {
863         ret = IEnumRfc1766_Next(pEnumRfc1766, 1, &info, &n);
864         if (ret != S_OK) break;
865
866 #ifdef DUMP_CP_INFO
867         trace("lcid %04x rfc_name %s locale_name %s\n",
868               info.lcid, wine_dbgstr_w(info.wszRfc1766), wine_dbgstr_w(info.wszLocaleName));
869 #endif
870
871         ok(n == 1, "couldn't fetch 1 RFC1766INFO structure\n");
872
873         /* verify the Rfc1766 value */
874         ret = IMultiLanguage2_GetRfc1766FromLcid(iML2, info.lcid, &rfcstr);
875         ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
876
877         /* not an exact 1:1 correspondence between lcid and rfc1766 in the
878          * mlang database, e.g., nb-no -> 1044 -> no */
879         ok(strstrW(info.wszRfc1766, rfcstr) != NULL,
880            "Expected matching locale names\n");
881
882         SysFreeString(rfcstr);
883     }
884     IEnumRfc1766_Release(pEnumRfc1766);
885 }
886
887 static void test_GetLcidFromRfc1766(IMultiLanguage2 *iML2)
888 {
889     WCHAR rfc1766W[MAX_RFC1766_NAME + 1];
890     LCID lcid;
891     HRESULT ret;
892     DWORD i;
893
894     static WCHAR en[] = { 'e','n',0 };
895     static WCHAR en_them[] = { 'e','n','-','t','h','e','m',0 };
896     static WCHAR english[] = { 'e','n','g','l','i','s','h',0 };
897
898
899     for(i = 0; i < sizeof(lcid_table) / sizeof(lcid_table[0]); i++) {
900         lcid = -1;
901         MultiByteToWideChar(CP_ACP, 0, lcid_table[i].rfc1766, -1, rfc1766W, MAX_RFC1766_NAME);
902         ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, rfc1766W);
903
904         ok(ret == lcid_table[i].hr,
905             "#%02d: HRESULT 0x%x (expected 0x%x)\n", i, ret, lcid_table[i].hr);
906
907         ok(lcid == lcid_table[i].lcid,
908             "#%02d: got LCID 0x%x (expected 0x%x)\n", i, lcid, lcid_table[i].lcid);
909     }
910
911
912     ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, NULL, en);
913     ok(ret == E_INVALIDARG, "GetLcidFromRfc1766 returned: %08x\n", ret);
914
915     ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, NULL);
916     ok(ret == E_INVALIDARG, "GetLcidFromRfc1766 returned: %08x\n", ret);
917
918     ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, en_them);
919     ok((ret == E_FAIL || ret == S_FALSE), "GetLcidFromRfc1766 returned: %08x\n", ret);
920     if (ret == S_FALSE)
921     {
922         BSTR rfcstr;
923         static WCHAR en[] = {'e','n',0};
924
925         ret = IMultiLanguage2_GetRfc1766FromLcid(iML2, lcid, &rfcstr);
926         ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
927         ok_w2("Expected \"%s\",  got \"%s\"n", en, rfcstr);
928     }
929
930     ret = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, english);
931     ok((ret == E_FAIL || ret == S_FALSE), "GetLcidFromRfc1766 returned: %08x\n", ret);
932     if (ret == S_FALSE)
933     {
934         BSTR rfcstr;
935         static WCHAR en[] = {'e','n',0};
936
937         ret = IMultiLanguage2_GetRfc1766FromLcid(iML2, lcid, &rfcstr);
938         ok(ret == S_OK, "Expected S_OK, got %08x\n", ret);
939         ok_w2("Expected \"%s\",  got \"%s\"n", en, rfcstr);
940     }
941
942 }
943
944 static void test_Rfc1766ToLcid(void)
945 {
946     LCID lcid;
947     HRESULT ret;
948     DWORD i;
949
950     for(i = 0; i < sizeof(lcid_table) / sizeof(lcid_table[0]); i++) {
951         lcid = -1;
952         ret = Rfc1766ToLcidA(&lcid, lcid_table[i].rfc1766);
953
954         ok(ret == lcid_table[i].hr,
955             "#%02d: HRESULT 0x%x (expected 0x%x)\n", i, ret, lcid_table[i].hr);
956
957
958         ok(lcid == lcid_table[i].lcid,
959             "#%02d: got LCID 0x%x (expected 0x%x)\n", i, lcid, lcid_table[i].lcid);
960
961     }
962
963     ret = Rfc1766ToLcidA(&lcid, NULL);
964     ok(ret == E_INVALIDARG, "got 0x%08x (expected E_INVALIDARG)\n", ret);
965
966     ret = Rfc1766ToLcidA(NULL, "en");
967     ok(ret == E_INVALIDARG, "got 0x%08x (expected E_INVALIDARG)\n", ret);
968
969 }
970
971
972 static void test_GetRfc1766FromLcid(IMultiLanguage2 *iML2)
973 {
974     CHAR expected[MAX_RFC1766_NAME];
975     CHAR buffer[MAX_RFC1766_NAME + 1];
976     DWORD i;
977     HRESULT hr;
978     BSTR rfcstr;
979
980     for(i = 0; i < sizeof(lcid_table) / sizeof(lcid_table[0]); i++) {
981         buffer[0] = '\0';
982
983         rfcstr = NULL;
984         hr = IMultiLanguage2_GetRfc1766FromLcid(iML2, lcid_table[i].lcid, &rfcstr);
985         ok(hr == lcid_table[i].hr,
986             "#%02d: HRESULT 0x%x (expected 0x%x)\n", i, hr, lcid_table[i].hr);
987
988         if (hr != S_OK)
989             continue;   /* no result-string created */
990
991         WideCharToMultiByte(CP_ACP, 0, rfcstr, -1, buffer, sizeof(buffer), NULL, NULL);
992         LCMapStringA(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, lcid_table[i].rfc1766,
993                     lstrlenA(lcid_table[i].rfc1766) + 1, expected, MAX_RFC1766_NAME);
994
995         ok(!lstrcmpA(buffer, expected),
996             "#%02d: got '%s' (expected '%s')\n", i, buffer, expected);
997
998         SysFreeString(rfcstr);
999     }
1000
1001     hr = IMultiLanguage2_GetRfc1766FromLcid(iML2, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NULL);
1002     ok(hr == E_INVALIDARG, "got 0x%x (expected E_INVALIDARG)\n", hr);
1003 }
1004
1005 static void test_LcidToRfc1766(void)
1006 {
1007     CHAR expected[MAX_RFC1766_NAME];
1008     CHAR buffer[MAX_RFC1766_NAME * 2];
1009     HRESULT hr;
1010     DWORD i;
1011
1012     for(i = 0; i < sizeof(lcid_table) / sizeof(lcid_table[0]); i++) {
1013
1014         memset(buffer, '#', sizeof(buffer)-1);
1015         buffer[sizeof(buffer)-1] = '\0';
1016
1017         hr = LcidToRfc1766A(lcid_table[i].lcid, buffer, MAX_RFC1766_NAME);
1018
1019         ok(hr == lcid_table[i].hr,
1020             "#%02d: HRESULT 0x%x (expected 0x%x)\n", i, hr, lcid_table[i].hr);
1021
1022         if (hr != S_OK)
1023             continue;
1024
1025         LCMapStringA(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, lcid_table[i].rfc1766,
1026                     lstrlenA(lcid_table[i].rfc1766) + 1, expected, MAX_RFC1766_NAME);
1027
1028         ok(!lstrcmpA(buffer, expected),
1029             "#%02d: got '%s' (expected '%s')\n", i, buffer, expected);
1030
1031     }
1032
1033     memset(buffer, '#', sizeof(buffer)-1);
1034     buffer[sizeof(buffer)-1] = '\0';
1035     hr = LcidToRfc1766A(-1, buffer, MAX_RFC1766_NAME);
1036     ok(hr == E_FAIL, "got 0x%08x and '%s' (expected E_FAIL)\n", hr, buffer);
1037
1038     hr = LcidToRfc1766A(LANG_ENGLISH, NULL, MAX_RFC1766_NAME);
1039     ok(hr == E_INVALIDARG, "got 0x%08x (expected E_INVALIDARG)\n", hr);
1040
1041     memset(buffer, '#', sizeof(buffer)-1);
1042     buffer[sizeof(buffer)-1] = '\0';
1043     hr = LcidToRfc1766A(LANG_ENGLISH, buffer, -1);
1044     ok(hr == E_INVALIDARG, "got 0x%08x and '%s' (expected E_INVALIDARG)\n", hr, buffer);
1045
1046     memset(buffer, '#', sizeof(buffer)-1);
1047     buffer[sizeof(buffer)-1] = '\0';
1048     hr = LcidToRfc1766A(LANG_ENGLISH, buffer, 0);
1049     ok(hr == E_INVALIDARG, "got 0x%08x and '%s' (expected E_INVALIDARG)\n", hr, buffer);
1050
1051 }
1052
1053 static void test_IMultiLanguage2_ConvertStringFromUnicode(IMultiLanguage2 *iML2)
1054 {
1055     CHAR dest[MAX_PATH];
1056     CHAR invariate[MAX_PATH];
1057     UINT srcsz, destsz;
1058     HRESULT hr;
1059
1060     static WCHAR src[] = {'a','b','c',0};
1061
1062     memset(invariate, 'x', sizeof(invariate));
1063
1064     /* pSrcStr NULL */
1065     memset(dest, 'x', sizeof(dest));
1066     srcsz = lstrlenW(src) + 1;
1067     destsz = sizeof(dest);
1068     hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, NULL,
1069                                                   &srcsz, dest, &destsz);
1070     ok(hr == S_OK || hr == E_FAIL,"expected S_OK or E_FAIL, got %08x\n",hr);
1071     if (hr == S_OK)
1072     {
1073         ok(srcsz == lstrlenW(src) + 1,
1074            "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1075     }
1076     else if (hr == E_FAIL)
1077     {
1078         ok(srcsz == 0,
1079            "Expected %u, got %u\n", 0, srcsz);
1080     }
1081
1082     ok(!memcmp(dest, invariate, sizeof(dest)),
1083        "Expected dest to be unchanged, got %s\n", dest);
1084     ok(destsz == 0, "Expected 0, got %u\n", destsz);
1085
1086     /* pcSrcSize NULL */
1087     memset(dest, 'x', sizeof(dest));
1088     destsz = sizeof(dest);
1089     hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1090                                                   NULL, dest, &destsz);
1091     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1092     ok(!strncmp(dest, "abc", 3),
1093        "Expected first three chars to be \"abc\"\n");
1094     ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1095        "Expected rest of dest to be unchanged, got %s\n", dest);
1096     ok(destsz == lstrlenW(src),
1097        "Expected %u, got %u\n", lstrlenW(src), destsz);
1098
1099     /* both pSrcStr and pcSrcSize NULL */
1100     memset(dest, 'x', sizeof(dest));
1101     destsz = sizeof(dest);
1102     hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, NULL,
1103                                                   NULL, dest, &destsz);
1104     ok(hr == S_OK || hr == E_FAIL, "Expected S_OK or E_FAIL, got %08x\n", hr);
1105     ok(!memcmp(dest, invariate, sizeof(dest)),
1106        "Expected dest to be unchanged, got %s\n", dest);
1107     ok(destsz == 0, "Expected 0, got %u\n", destsz);
1108
1109     /* pDstStr NULL */
1110     memset(dest, 'x', sizeof(dest));
1111     srcsz = lstrlenW(src) + 1;
1112     destsz = sizeof(dest);
1113     hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1114                                                   &srcsz, NULL, &destsz);
1115     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1116     ok(srcsz == lstrlenW(src) + 1,
1117        "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1118     ok(destsz == lstrlenW(src) + 1,
1119        "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1120
1121     /* pcDstSize NULL */
1122     memset(dest, 'x', sizeof(dest));
1123     hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1124                                                   &srcsz, dest, NULL);
1125     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1126     ok(srcsz == lstrlenW(src) + 1,
1127        "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1128     ok(!memcmp(dest, invariate, sizeof(dest)),
1129        "Expected dest to be unchanged, got %s\n", dest);
1130
1131     /* pcSrcSize is 0 */
1132     memset(dest, 'x', sizeof(dest));
1133     srcsz = 0;
1134     destsz = sizeof(dest);
1135     hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1136                                                   &srcsz, dest, &destsz);
1137     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1138     ok(srcsz == 0, "Expected 0, got %u\n", srcsz);
1139     ok(!memcmp(dest, invariate, sizeof(dest)),
1140        "Expected dest to be unchanged, got %s\n", dest);
1141     ok(destsz == 0, "Expected 0, got %u\n", destsz);
1142
1143     /* pcSrcSize does not include NULL terminator */
1144     memset(dest, 'x', sizeof(dest));
1145     srcsz = lstrlenW(src);
1146     destsz = sizeof(dest);
1147     hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1148                                                   &srcsz, dest, &destsz);
1149     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1150     ok(srcsz == lstrlenW(src),
1151        "Expected %u, got %u\n", lstrlenW(src), srcsz);
1152     ok(!strncmp(dest, "abc", 3), "Expected first three chars to be \"abc\"\n");
1153     ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1154        "Expected rest of dest to be unchanged, got %s\n", dest);
1155     ok(destsz == lstrlenW(src),
1156        "Expected %u, got %u\n", lstrlenW(src), destsz);
1157
1158     /* pcSrcSize includes NULL terminator */
1159     memset(dest, 'x', sizeof(dest));
1160     srcsz = lstrlenW(src) + 1;
1161     destsz = sizeof(dest);
1162     hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1163                                                   &srcsz, dest, &destsz);
1164     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1165     ok(srcsz == lstrlenW(src) + 1, "Expected 3, got %u\n", srcsz);
1166     ok(!lstrcmpA(dest, "abc"), "Expected \"abc\", got \"%s\"\n", dest);
1167     ok(destsz == lstrlenW(src) + 1,
1168        "Expected %u, got %u\n", lstrlenW(src) + 1, destsz);
1169
1170     /* pcSrcSize is -1 */
1171     memset(dest, 'x', sizeof(dest));
1172     srcsz = -1;
1173     destsz = sizeof(dest);
1174     hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1175                                                   &srcsz, dest, &destsz);
1176     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1177     ok(srcsz == lstrlenW(src),
1178        "Expected %u, got %u\n", lstrlenW(src), srcsz);
1179     ok(!strncmp(dest, "abc", 3), "Expected first three chars to be \"abc\"\n");
1180     ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1181        "Expected rest of dest to be unchanged, got %s\n", dest);
1182     ok(destsz == lstrlenW(src),
1183        "Expected %u, got %u\n", lstrlenW(src), destsz);
1184
1185     /* pcDstSize is 0 */
1186     memset(dest, 'x', sizeof(dest));
1187     srcsz = lstrlenW(src) + 1;
1188     destsz = 0;
1189     hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1190                                                   &srcsz, dest, &destsz);
1191     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1192     ok(srcsz == lstrlenW(src) + 1,
1193        "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1194     ok(!memcmp(dest, invariate, sizeof(dest)),
1195        "Expected dest to be unchanged, got %s\n", dest);
1196     ok(destsz == lstrlenW(src) + 1,
1197        "Expected %u, got %u\n", lstrlenW(src) + 1, destsz);
1198
1199     /* pcDstSize is not large enough */
1200     memset(dest, 'x', sizeof(dest));
1201     srcsz = lstrlenW(src) + 1;
1202     destsz = lstrlenW(src);
1203     hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1204                                                   &srcsz, dest, &destsz);
1205     ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
1206     ok(srcsz == 0, "Expected 0, got %u\n", srcsz);
1207     ok(!strncmp(dest, "abc", 3), "Expected first three chars to be \"abc\"\n");
1208     ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1209        "Expected rest of dest to be unchanged, got %s\n", dest);
1210     ok(destsz == 0, "Expected 0, got %u\n", srcsz);
1211
1212     /* pcDstSize (bytes) does not leave room for NULL terminator */
1213     memset(dest, 'x', sizeof(dest));
1214     srcsz = lstrlenW(src) + 1;
1215     destsz = lstrlenW(src) * sizeof(WCHAR);
1216     hr = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, src,
1217                                                   &srcsz, dest, &destsz);
1218     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1219     ok(srcsz == lstrlenW(src) + 1,
1220        "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1221     ok(!lstrcmpA(dest, "abc"), "Expected \"abc\", got \"%s\"\n", dest);
1222     ok(destsz == lstrlenW(src) + 1,
1223        "Expected %u, got %u\n", lstrlenW(src) + 1, destsz);
1224 }
1225
1226 static void test_ConvertINetUnicodeToMultiByte(void)
1227 {
1228     CHAR dest[MAX_PATH];
1229     CHAR invariate[MAX_PATH];
1230     INT srcsz, destsz;
1231     HRESULT hr;
1232
1233     static WCHAR src[] = {'a','b','c',0};
1234
1235     memset(invariate, 'x', sizeof(invariate));
1236
1237     /* lpSrcStr NULL */
1238     memset(dest, 'x', sizeof(dest));
1239     srcsz = lstrlenW(src) + 1;
1240     destsz = sizeof(dest);
1241     hr = pConvertINetUnicodeToMultiByte(NULL, 1252, NULL, &srcsz, dest, &destsz);
1242     ok(hr == S_OK || hr == E_FAIL, "Expected S_OK or E_FAIL, got %08x\n", hr);
1243     if (hr == S_OK)
1244         ok(srcsz == lstrlenW(src) + 1,
1245            "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1246     else if (hr == E_FAIL)
1247         ok(srcsz == 0,
1248            "Expected %u, got %u\n", 0, srcsz);
1249     ok(!memcmp(dest, invariate, sizeof(dest)),
1250        "Expected dest to be unchanged, got %s\n", dest);
1251     ok(destsz == 0, "Expected 0, got %u\n", destsz);
1252
1253     /* lpnWideCharCount NULL */
1254     memset(dest, 'x', sizeof(dest));
1255     destsz = sizeof(dest);
1256     hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, NULL, dest, &destsz);
1257     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1258     ok(!strncmp(dest, "abc", 3),
1259        "Expected first three chars to be \"abc\"\n");
1260     ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1261        "Expected rest of dest to be unchanged, got %s\n", dest);
1262     ok(destsz == lstrlenW(src),
1263        "Expected %u, got %u\n", lstrlenW(src), destsz);
1264
1265     /* both lpSrcStr and lpnWideCharCount NULL */
1266     memset(dest, 'x', sizeof(dest));
1267     destsz = sizeof(dest);
1268     hr = pConvertINetUnicodeToMultiByte(NULL, 1252, NULL, NULL, dest, &destsz);
1269     ok(hr == S_OK || hr == E_FAIL, "Expected S_OK or E_FAIL, got %08x\n", hr);
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);
1273
1274     /* lpDstStr NULL */
1275     memset(dest, 'x', sizeof(dest));
1276     srcsz = lstrlenW(src) + 1;
1277     destsz = sizeof(dest);
1278     hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, NULL, &destsz);
1279     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1280     ok(srcsz == lstrlenW(src) + 1,
1281        "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1282     ok(destsz == lstrlenW(src) + 1,
1283        "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1284
1285     /* lpnMultiCharCount NULL */
1286     memset(dest, 'x', sizeof(dest));
1287     hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, NULL);
1288     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1289     ok(srcsz == lstrlenW(src) + 1,
1290        "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1291     ok(!memcmp(dest, invariate, sizeof(dest)),
1292        "Expected dest to be unchanged, got %s\n", dest);
1293
1294     /* lpnWideCharCount is 0 */
1295     memset(dest, 'x', sizeof(dest));
1296     srcsz = 0;
1297     destsz = sizeof(dest);
1298     hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, &destsz);
1299     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1300     ok(srcsz == 0, "Expected 0, got %u\n", srcsz);
1301     ok(!memcmp(dest, invariate, sizeof(dest)),
1302        "Expected dest to be unchanged, got %s\n", dest);
1303     ok(destsz == 0, "Expected 0, got %u\n", destsz);
1304
1305     /* lpnWideCharCount does not include NULL terminator */
1306     memset(dest, 'x', sizeof(dest));
1307     srcsz = lstrlenW(src);
1308     destsz = sizeof(dest);
1309     hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, &destsz);
1310     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1311     ok(srcsz == lstrlenW(src),
1312        "Expected %u, got %u\n", lstrlenW(src), srcsz);
1313     ok(!strncmp(dest, "abc", 3), "Expected first three chars to be \"abc\"\n");
1314     ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1315        "Expected rest of dest to be unchanged, got %s\n", dest);
1316     ok(destsz == lstrlenW(src),
1317        "Expected %u, got %u\n", lstrlenW(src), destsz);
1318
1319     /* lpnWideCharCount includes NULL terminator */
1320     memset(dest, 'x', sizeof(dest));
1321     srcsz = lstrlenW(src) + 1;
1322     destsz = sizeof(dest);
1323     hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, &destsz);
1324     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1325     ok(srcsz == lstrlenW(src) + 1, "Expected 3, got %u\n", srcsz);
1326     ok(!lstrcmpA(dest, "abc"), "Expected \"abc\", got \"%s\"\n", dest);
1327     ok(destsz == lstrlenW(src) + 1,
1328        "Expected %u, got %u\n", lstrlenW(src) + 1, destsz);
1329
1330     /* lpnWideCharCount is -1 */
1331     memset(dest, 'x', sizeof(dest));
1332     srcsz = -1;
1333     destsz = sizeof(dest);
1334     hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, &destsz);
1335     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1336     ok(srcsz == lstrlenW(src),
1337        "Expected %u, got %u\n", lstrlenW(src), srcsz);
1338     ok(!strncmp(dest, "abc", 3), "Expected first three chars to be \"abc\"\n");
1339     ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1340        "Expected rest of dest to be unchanged, got %s\n", dest);
1341     ok(destsz == lstrlenW(src),
1342        "Expected %u, got %u\n", lstrlenW(src), destsz);
1343
1344     /* lpnMultiCharCount is 0 */
1345     memset(dest, 'x', sizeof(dest));
1346     srcsz = lstrlenW(src) + 1;
1347     destsz = 0;
1348     hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, &destsz);
1349     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1350     ok(srcsz == lstrlenW(src) + 1,
1351        "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1352     ok(!memcmp(dest, invariate, sizeof(dest)),
1353        "Expected dest to be unchanged, got %s\n", dest);
1354     ok(destsz == lstrlenW(src) + 1,
1355        "Expected %u, got %u\n", lstrlenW(src) + 1, destsz);
1356
1357     /* lpnMultiCharCount is not large enough */
1358     memset(dest, 'x', sizeof(dest));
1359     srcsz = lstrlenW(src) + 1;
1360     destsz = lstrlenW(src);
1361     hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, &destsz);
1362     ok(hr == E_FAIL, "Expected E_FAIL, got %08x\n", hr);
1363     ok(srcsz == 0, "Expected 0, got %u\n", srcsz);
1364     ok(!strncmp(dest, "abc", 3), "Expected first three chars to be \"abc\"\n");
1365     ok(!memcmp(&dest[3], invariate, sizeof(dest) - 3),
1366        "Expected rest of dest to be unchanged, got %s\n", dest);
1367     ok(destsz == 0, "Expected 0, got %u\n", srcsz);
1368
1369     /* lpnMultiCharCount (bytes) does not leave room for NULL terminator */
1370     memset(dest, 'x', sizeof(dest));
1371     srcsz = lstrlenW(src) + 1;
1372     destsz = lstrlenW(src) * sizeof(WCHAR);
1373     hr = pConvertINetUnicodeToMultiByte(NULL, 1252, src, &srcsz, dest, &destsz);
1374     ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
1375     ok(srcsz == lstrlenW(src) + 1,
1376        "Expected %u, got %u\n", lstrlenW(src) + 1, srcsz);
1377     ok(!lstrcmpA(dest, "abc"), "Expected \"abc\", got \"%s\"\n", dest);
1378     ok(destsz == lstrlenW(src) + 1,
1379        "Expected %u, got %u\n", lstrlenW(src) + 1, destsz);
1380 }
1381
1382 static void test_JapaneseConversion(void)
1383 {
1384     /* Data */
1385     static WCHAR unc_jp[9][12] = {
1386   {9,0x31,0x20,0x3042,0x3044,0x3046,0x3048,0x304a,0x000d,0x000a},
1387   {9,0x31,0x20,0x30a2,0x30a4,0x30a6,0x30a8,0x30aa,0x000d,0x000a},
1388   {9,0x31,0x20,0xff71,0xff72,0xff73,0xff74,0xff75,0x000d,0x000a},
1389   {9,0x31,0x20,0x3041,0x3043,0x3045,0x3047,0x3049,0x000d,0x000a},
1390   {9,0x31,0x20,0x30a1,0x30a3,0x30a5,0x30a7,0x30a9,0x000d,0x000a},
1391   {9,0x31,0x20,0xff67,0xff68,0xff69,0xff6a,0xff6b,0x000d,0x000a},
1392   {9,0x31,0x20,0x300c,0x65e5,0x672c,0x8a9e,0x300d,0x000d,0x000a},
1393   {7,0x31,0x20,0x25c7,0x25c7,0x3012,0x000d,0x000a},
1394   {11,0x31,0x20,0x203b,0x3010,0x0074,0x0065,0x0073,0x0074,0x3011,0x000d,0x000a}
1395     };
1396     static CHAR jis_jp[9][27] = {
1397   {20,0x31,0x20,0x1b,0x24,0x42,0x24,0x22,0x24,0x24,0x24,0x26,0x24,0x28,
1398       0x24,0x2a,0x1b,0x28,0x42,0x0d,0x0a},
1399   {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x22,0x25,0x24,0x25,0x26,0x25,0x28,
1400       0x25,0x2a,0x1b,0x28,0x42,0x0d,0x0a},
1401   {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x22,0x25,0x24,0x25,0x26,0x25,0x28,
1402       0x25,0x2a,0x1b,0x28,0x42,0x0d,0x0a},
1403   {20,0x31,0x20,0x1b,0x24,0x42,0x24,0x21,0x24,0x23,0x24,0x25,0x24,0x27,
1404       0x24,0x29,0x1b,0x28,0x42,0x0d,0x0a},
1405   {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x21,0x25,0x23,0x25,0x25,0x25,0x27,
1406       0x25,0x29,0x1b,0x28,0x42,0x0d,0x0a},
1407   {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x21,0x25,0x23,0x25,0x25,0x25,0x27,
1408       0x25,0x29,0x1b,0x28,0x42,0x0d,0x0a},
1409   {20,0x31,0x20,0x1b,0x24,0x42,0x21,0x56,0x46,0x7c,0x4b,0x5c,0x38,0x6c,
1410       0x21,0x57,0x1b,0x28,0x42,0x0d,0x0a},
1411   {16,0x31,0x20,0x1b,0x24,0x42,0x21,0x7e,0x21,0x7e,0x22,0x29,0x1b,0x28,
1412       0x42,0x0d,0x0a},
1413   {26,0x31,0x20,0x1b,0x24,0x42,0x22,0x28,0x21,0x5a,0x1b,0x28,0x42,0x74,
1414       0x65,0x73,0x74,0x1b,0x24,0x42,0x21,0x5b,0x1b,0x28,0x42,0x0d,0x0a}
1415     };
1416     static CHAR sjis_jp[9][15] = {
1417   {14,0x31,0x20,0x82,0xa0,0x82,0xa2,0x82,0xa4,0x82,0xa6,0x82,0xa8,0x0d,0x0a},
1418   {14,0x31,0x20,0x83,0x41,0x83,0x43,0x83,0x45,0x83,0x47,0x83,0x49,0x0d,0x0a},
1419   {9,0x31,0x20,0xb1,0xb2,0xb3,0xb4,0xb5,0x0d,0x0a},
1420   {14,0x31,0x20,0x82,0x9f,0x82,0xa1,0x82,0xa3,0x82,0xa5,0x82,0xa7,0x0d,0x0a},
1421   {14,0x31,0x20,0x83,0x40,0x83,0x42,0x83,0x44,0x83,0x46,0x83,0x48,0x0d,0x0a},
1422   {9,0x31,0x20,0xa7,0xa8,0xa9,0xaa,0xab,0x0d,0x0a},
1423   {14,0x31,0x20,0x81,0x75,0x93,0xfa,0x96,0x7b,0x8c,0xea,0x81,0x76,0x0d,0x0a},
1424   {10,0x31,0x20,0x81,0x9e,0x81,0x9e,0x81,0xa7,0x0d,0x0a},
1425   {14,0x31,0x20,0x81,0xa6,0x81,0x79,0x74,0x65,0x73,0x74,0x81,0x7a,0x0d,0x0a}
1426     };
1427     static CHAR euc_jp[9][15] = {
1428   {14,0x31,0x20,0xa4,0xa2,0xa4,0xa4,0xa4,0xa6,0xa4,0xa8,0xa4,0xaa,0x0d,0x0a},
1429   {14,0x31,0x20,0xa5,0xa2,0xa5,0xa4,0xa5,0xa6,0xa5,0xa8,0xa5,0xaa,0x0d,0x0a},
1430   {14,0x31,0x20,0x8e,0xb1,0x8e,0xb2,0x8e,0xb3,0x8e,0xb4,0x8e,0xb5,0x0d,0x0a},
1431   {14,0x31,0x20,0xa4,0xa1,0xa4,0xa3,0xa4,0xa5,0xa4,0xa7,0xa4,0xa9,0x0d,0x0a},
1432   {14,0x31,0x20,0xa5,0xa1,0xa5,0xa3,0xa5,0xa5,0xa5,0xa7,0xa5,0xa9,0x0d,0x0a},
1433   {14,0x31,0x20,0x8e,0xa7,0x8e,0xa8,0x8e,0xa9,0x8e,0xaa,0x8e,0xab,0x0d,0x0a},
1434   {14,0x31,0x20,0xa1,0xd6,0xc6,0xfc,0xcb,0xdc,0xb8,0xec,0xa1,0xd7,0x0d,0x0a},
1435   {10,0x31,0x20,0xa1,0xfe,0xa1,0xfe,0xa2,0xa9,0x0d,0x0a},
1436   {14,0x31,0x20,0xa2,0xa8,0xa1,0xda,0x74,0x65,0x73,0x74,0xa1,0xdb,0x0d,0x0a}
1437     };
1438
1439     INT srcsz, destsz;
1440     INT i;
1441     HRESULT hr;
1442     CHAR output[30];
1443     WCHAR outputW[30];
1444     int outlen;
1445
1446     /* test unc->jis */
1447     for (i = 0; i < 9; i++)
1448     {
1449         int j;
1450         destsz = 30;
1451         outlen = jis_jp[i][0];
1452         srcsz = unc_jp[i][0];
1453         hr = pConvertINetUnicodeToMultiByte(NULL, 50220, &unc_jp[i][1], &srcsz, output, &destsz);
1454         if (hr == S_FALSE)
1455         {
1456             skip("Code page identifier 50220 is not supported\n");
1457             break;
1458         }
1459         ok(hr == S_OK,"(%i) Expected S_OK, got %08x\n", i, hr);
1460         ok(destsz == outlen, "(%i) Expected %i, got %i\n",i,outlen,destsz);
1461         ok(srcsz == unc_jp[i][0],"(%i) Expected %i, got %i\n",i,unc_jp[i][0],srcsz);
1462         ok(memcmp(output,&jis_jp[i][1],destsz)==0,"(%i) Strings do not match\n",i);
1463
1464         /* and back */
1465         srcsz = outlen;
1466         destsz = 30;
1467         hr = pConvertINetMultiByteToUnicode(NULL, 50220, output, &srcsz, outputW,&destsz);
1468
1469         /*
1470          * JIS does not have hankata so it get automatically converted to
1471          * zenkata. this means that strings 1 and 2 are identical as well as
1472          * strings 4 and 5.
1473          */
1474         j = i;
1475         if (i == 2) j = 1;
1476         if (i == 5) j = 4;
1477
1478         ok(hr == S_OK,"(%i) Expected S_OK, got %08x\n",i, hr);
1479         ok(destsz == unc_jp[j][0],"(%i) Expected %i, got %i\n",i,unc_jp[j][0],destsz);
1480         ok(srcsz == outlen,"(%i) Expected %i, got %i\n",i,outlen,srcsz);
1481         ok(memcmp(outputW,&unc_jp[j][1],destsz)==0,"(%i) Strings do not match\n",i);
1482     }
1483
1484     /* test unc->sjis */
1485     for (i = 0; i < 9; i++)
1486     {
1487         destsz = 30;
1488         outlen = sjis_jp[i][0];
1489         srcsz = unc_jp[i][0];
1490
1491         hr = pConvertINetUnicodeToMultiByte(NULL, 932, &unc_jp[i][1], &srcsz, output, &destsz);
1492         if (hr == S_FALSE)
1493         {
1494             skip("Code page identifier 932 is not supported\n");
1495             break;
1496         }
1497         ok(hr == S_OK,"(%i) Expected S_OK, got %08x\n",i,hr);
1498         ok(destsz == outlen,"(%i) Expected %i, got %i\n",i,outlen,destsz);
1499         ok(srcsz == unc_jp[i][0],"(%i) Expected %i, got %i\n",i,unc_jp[i][0],srcsz);
1500         ok(memcmp(output,&sjis_jp[i][1],outlen)==0,"(%i) Strings do not match\n",i);
1501
1502         srcsz = outlen;
1503         destsz = 30;
1504         hr = pConvertINetMultiByteToUnicode(NULL, 932, output, &srcsz, outputW,&destsz);
1505
1506         ok(hr == S_OK,"(%i) Expected S_OK, got %08x\n", i, hr);
1507         ok(destsz == unc_jp[i][0],"(%i) Expected %i, got %i\n",i,unc_jp[i][0],destsz);
1508         ok(srcsz == outlen,"(%i) Expected %i, got %i\n",i,outlen,srcsz);
1509         ok(memcmp(outputW,&unc_jp[i][1],destsz)==0,"(%i) Strings do not match\n",i);
1510     }
1511
1512     /* test unc->euc */
1513     for (i = 0; i < 9; i++)
1514     {
1515         destsz = 30;
1516         outlen = euc_jp[i][0];
1517         srcsz = unc_jp[i][0];
1518
1519         hr = pConvertINetUnicodeToMultiByte(NULL, 51932, &unc_jp[i][1], &srcsz, output, &destsz);
1520         if (hr == S_FALSE)
1521         {
1522             skip("Code page identifier 51932 is not supported\n");
1523             break;
1524         }
1525         ok(hr == S_OK, "(%i) Expected S_OK, got %08x\n",i,hr);
1526         ok(destsz == outlen, "(%i) Expected %i, got %i\n",i,outlen,destsz);
1527         ok(srcsz == unc_jp[i][0],"(%i) Expected %i, got %i\n",i,unc_jp[i][0],destsz);
1528         ok(memcmp(output,&euc_jp[i][1],outlen)==0,"(%i) Strings do not match\n",i);
1529
1530         srcsz = outlen;
1531         destsz = 30;
1532         hr = pConvertINetMultiByteToUnicode(NULL, 51932, output, &srcsz, outputW,&destsz);
1533
1534         ok(hr == S_OK,"(%i) Expected S_OK, got %08x\n",i,hr);
1535         ok(destsz == unc_jp[i][0],"(%i) Expected %i, got %i\n",i,unc_jp[i][0],destsz);
1536         ok(srcsz == outlen,"(%i) Expected %i, got %i\n",i,outlen,srcsz);
1537         ok(memcmp(outputW,&unc_jp[i][1],destsz)==0,"(%i) Strings do not match\n",i);
1538     }
1539
1540     /* Japanese autodetect */
1541     i = 0;
1542     destsz = 30;
1543     srcsz = jis_jp[i][0];
1544     hr = pConvertINetMultiByteToUnicode(NULL, 50932, &jis_jp[i][1], &srcsz, outputW, &destsz);
1545     if (hr == S_FALSE)
1546     {
1547         skip("Code page identifier 50932 is not supported\n");
1548         return;
1549     }
1550     ok(hr == S_OK,"(%i) Expected S_OK, got %08x\n",i,hr);
1551     ok(destsz == unc_jp[i][0],"(%i) Expected %i, got %i\n",i,unc_jp[i][0],destsz);
1552     ok(srcsz == jis_jp[i][0],"(%i) Expected %i, got %i\n",i,jis_jp[i][0],srcsz);
1553     ok(memcmp(outputW,&unc_jp[i][1],destsz)==0,"(%i) Strings do not match\n",i);
1554
1555     i = 1;
1556     destsz = 30;
1557     srcsz = sjis_jp[i][0];
1558     hr = pConvertINetMultiByteToUnicode(NULL, 50932, &sjis_jp[i][1], &srcsz, outputW, &destsz);
1559     ok(hr == S_OK,"(%i) Expected S_OK, got %08x\n",i,hr);
1560     ok(destsz == unc_jp[i][0],"(%i) Expected %i, got %i\n",i,unc_jp[i][0],destsz);
1561     ok(srcsz == sjis_jp[i][0],"(%i) Expected %i, got %i\n",i,sjis_jp[i][0],srcsz);
1562     ok(memcmp(outputW,&unc_jp[i][1],destsz)==0,"(%i) Strings do not match\n",i);
1563 }
1564
1565 static void test_GetScriptFontInfo(IMLangFontLink2 *font_link)
1566 {
1567     HRESULT hr;
1568     UINT nfonts;
1569     SCRIPTFONTINFO sfi[1];
1570
1571     nfonts = 0;
1572     hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidLatin, 0, &nfonts, NULL);
1573     ok(hr == S_OK, "GetScriptFontInfo failed %u\n", GetLastError());
1574     ok(nfonts, "unexpected result\n");
1575
1576     nfonts = 0;
1577     hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidLatin, SCRIPTCONTF_FIXED_FONT, &nfonts, NULL);
1578     ok(hr == S_OK, "GetScriptFontInfo failed %u\n", GetLastError());
1579     ok(nfonts, "unexpected result\n");
1580
1581     nfonts = 0;
1582     hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidLatin, SCRIPTCONTF_PROPORTIONAL_FONT, &nfonts, NULL);
1583     ok(hr == S_OK, "GetScriptFontInfo failed %u\n", GetLastError());
1584     ok(nfonts, "unexpected result\n");
1585
1586     nfonts = 1;
1587     memset(sfi, 0, sizeof(sfi));
1588     hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidLatin, SCRIPTCONTF_FIXED_FONT, &nfonts, sfi);
1589     ok(hr == S_OK, "GetScriptFontInfo failed %u\n", GetLastError());
1590     ok(nfonts == 1, "got %u, expected 1\n", nfonts);
1591     ok(sfi[0].scripts != 0, "unexpected result\n");
1592     ok(sfi[0].wszFont[0], "unexpected result\n");
1593
1594     nfonts = 1;
1595     memset(sfi, 0, sizeof(sfi));
1596     hr = IMLangFontLink2_GetScriptFontInfo(font_link, sidLatin, SCRIPTCONTF_PROPORTIONAL_FONT, &nfonts, sfi);
1597     ok(hr == S_OK, "GetScriptFontInfo failed %u\n", GetLastError());
1598     ok(nfonts == 1, "got %u, expected 1\n", nfonts);
1599     ok(sfi[0].scripts != 0, "unexpected result\n");
1600     ok(sfi[0].wszFont[0], "unexpected result\n");
1601 }
1602
1603 START_TEST(mlang)
1604 {
1605     IMultiLanguage2 *iML2 = NULL;
1606     IMLangFontLink  *iMLFL = NULL;
1607     IMLangFontLink2 *iMLFL2 = NULL;
1608     HRESULT ret;
1609
1610     if (!init_function_ptrs())
1611         return;
1612
1613     CoInitialize(NULL);
1614     test_Rfc1766ToLcid();
1615     test_LcidToRfc1766();
1616
1617     ret = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
1618                            &IID_IMultiLanguage2, (void **)&iML2);
1619     if (ret != S_OK || !iML2) return;
1620
1621     test_rfc1766(iML2);
1622     test_GetLcidFromRfc1766(iML2);
1623     test_GetRfc1766FromLcid(iML2);
1624
1625     test_EnumCodePages(iML2, 0);
1626     test_EnumCodePages(iML2, MIMECONTF_MIME_LATEST);
1627     test_EnumCodePages(iML2, MIMECONTF_BROWSER);
1628     test_EnumCodePages(iML2, MIMECONTF_MINIMAL);
1629     test_EnumCodePages(iML2, MIMECONTF_VALID);
1630     /* FIXME: why MIMECONTF_MIME_REGISTRY returns 0 of supported codepages? */
1631     /*test_EnumCodePages(iML2, MIMECONTF_MIME_REGISTRY);*/
1632
1633     test_EnumScripts(iML2, 0);
1634     test_EnumScripts(iML2, SCRIPTCONTF_SCRIPT_USER);
1635     test_EnumScripts(iML2, SCRIPTCONTF_SCRIPT_USER | SCRIPTCONTF_SCRIPT_HIDE | SCRIPTCONTF_SCRIPT_SYSTEM);
1636
1637     ret = IMultiLanguage2_IsConvertible(iML2, CP_UTF8, CP_UNICODE);
1638     ok(ret == S_OK, "IMultiLanguage2_IsConvertible(CP_UTF8 -> CP_UNICODE) = %08x\n", ret);
1639     ret = IMultiLanguage2_IsConvertible(iML2, CP_UNICODE, CP_UTF8);
1640     ok(ret == S_OK, "IMultiLanguage2_IsConvertible(CP_UNICODE -> CP_UTF8) = %08x\n", ret);
1641
1642     test_multibyte_to_unicode_translations(iML2);
1643     test_IMultiLanguage2_ConvertStringFromUnicode(iML2);
1644
1645     IMultiLanguage2_Release(iML2);
1646
1647     test_ConvertINetUnicodeToMultiByte();
1648
1649     test_JapaneseConversion();
1650
1651     ret = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
1652                            &IID_IMLangFontLink, (void **)&iMLFL);
1653     if (ret != S_OK || !iMLFL) return;
1654
1655     IMLangFontLink_Test(iMLFL);
1656     IMLangFontLink_Release(iMLFL);
1657
1658     ret = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
1659                            &IID_IMLangFontLink2, (void **)&iMLFL2);
1660     if (ret != S_OK || !iMLFL2) return;
1661
1662     test_GetScriptFontInfo(iMLFL2);
1663     IMLangFontLink2_Release(iMLFL2);
1664
1665     CoUninitialize();
1666 }