2 * Unit test suite for MLANG APIs.
4 * Copyright 2004 Dmitry Timoshkov
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wine/test.h"
34 #define CP_UNICODE 1200
39 #define DUMP_SCRIPT_INFO
41 #if defined DUMP_CP_INFO || defined DUMP_SCRIPT_INFO
42 #include "wine/debug.h"
46 static BOOL (WINAPI
*pGetCPInfoExA
)(UINT
, DWORD
, LPCPINFOEXA
);
47 static HRESULT (WINAPI
*pConvertINetMultiByteToUnicode
)(LPDWORD
, DWORD
, LPCSTR
,
48 LPINT
, LPWSTR
, LPINT
);
49 static HRESULT (WINAPI
*pConvertINetUnicodeToMultiByte
)(LPDWORD
, DWORD
, LPCWSTR
,
52 static BOOL
init_function_ptrs(void)
56 hMlang
= LoadLibraryA("mlang.dll");
59 skip("mlang not available\n");
63 pConvertINetMultiByteToUnicode
= (void *)GetProcAddress(hMlang
, "ConvertINetMultiByteToUnicode");
64 pConvertINetUnicodeToMultiByte
= (void *)GetProcAddress(hMlang
, "ConvertINetUnicodeToMultiByte");
66 pGetCPInfoExA
= (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetCPInfoExA");
71 #define ok_w2(format, szString1, szString2) \
73 if (lstrcmpW((szString1), (szString2)) != 0) \
75 CHAR string1[256], string2[256]; \
76 WideCharToMultiByte(CP_ACP, 0, (szString1), -1, string1, 256, NULL, NULL); \
77 WideCharToMultiByte(CP_ACP, 0, (szString2), -1, string2, 256, NULL, NULL); \
78 ok(0, (format), string1, string2); \
81 static void test_multibyte_to_unicode_translations(IMultiLanguage2
*iML2
)
83 /* these APIs are broken regarding constness of the input buffer */
84 char stringA
[] = "Just a test string\0"; /* double 0 for CP_UNICODE tests */
85 WCHAR stringW
[] = {'J','u','s','t',' ','a',' ','t','e','s','t',' ','s','t','r','i','n','g',0};
88 UINT lenA
, lenW
, expected_len
;
91 /* IMultiLanguage2_ConvertStringToUnicode tests */
93 memset(bufW
, 'x', sizeof(bufW
));
95 lenW
= sizeof(bufW
)/sizeof(bufW
[0]);
96 ret
= IMultiLanguage2_ConvertStringToUnicode(iML2
, NULL
, 1252, stringA
, &lenA
, bufW
, &lenW
);
97 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringToUnicode failed: %08x\n", ret
);
98 ok(lenA
== 0, "expected lenA 0, got %u\n", lenA
);
99 ok(lenW
== 0, "expected lenW 0, got %u\n", lenW
);
101 memset(bufW
, 'x', sizeof(bufW
));
103 lenW
= sizeof(bufW
)/sizeof(bufW
[0]);
104 ret
= IMultiLanguage2_ConvertStringToUnicode(iML2
, NULL
, 1252, stringA
, &lenA
, bufW
, &lenW
);
105 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringToUnicode failed: %08x\n", ret
);
106 ok(lenA
== lstrlenA(stringA
), "expected lenA %u, got %u\n", lstrlenA(stringA
), lenA
);
107 ok(lenW
== lstrlenW(stringW
), "expected lenW %u, got %u\n", lstrlenW(stringW
), lenW
);
108 if (lenW
< sizeof(bufW
)/sizeof(bufW
[0])) {
109 /* can only happen if the convert call fails */
110 ok(bufW
[lenW
] != 0, "buf should not be 0 terminated\n");
111 bufW
[lenW
] = 0; /* -1 doesn't include 0 terminator */
113 ok(!lstrcmpW(bufW
, stringW
), "bufW/stringW mismatch\n");
115 memset(bufW
, 'x', sizeof(bufW
));
118 ret
= IMultiLanguage2_ConvertStringToUnicode(iML2
, NULL
, 1252, stringA
, &lenA
, bufW
, &lenW
);
119 ok(ret
== E_FAIL
, "IMultiLanguage2_ConvertStringToUnicode should fail: %08x\n", ret
);
120 ok(lenW
== 0, "expected lenW 0, got %u\n", lenW
);
121 /* still has to do partial conversion */
122 ok(!memcmp(bufW
, stringW
, 5 * sizeof(WCHAR
)), "bufW/stringW mismatch\n");
124 memset(bufW
, 'x', sizeof(bufW
));
126 lenW
= sizeof(bufW
)/sizeof(bufW
[0]);
127 ret
= IMultiLanguage2_ConvertStringToUnicode(iML2
, NULL
, CP_UNICODE
, stringA
, &lenA
, bufW
, &lenW
);
128 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringToUnicode failed: %08x\n", ret
);
129 ok(lenA
== lstrlenA(stringA
), "expected lenA %u, got %u\n", lstrlenA(stringA
), lenA
);
130 ok(lenW
== lstrlenW(stringW
)/(int)sizeof(WCHAR
), "wrong lenW %u\n", lenW
);
131 ok(bufW
[lenW
] != 0, "buf should not be 0 terminated\n");
132 bufW
[lenW
] = 0; /* -1 doesn't include 0 terminator */
133 ok(!lstrcmpA((LPCSTR
)bufW
, stringA
), "bufW/stringA mismatch\n");
135 memset(bufW
, 'x', sizeof(bufW
));
136 lenA
= lstrlenA(stringA
);
138 ret
= IMultiLanguage2_ConvertStringToUnicode(iML2
, NULL
, 1252, stringA
, &lenA
, NULL
, &lenW
);
139 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringToUnicode failed: %08x\n", ret
);
140 ok(lenA
== lstrlenA(stringA
), "expected lenA %u, got %u\n", lstrlenA(stringA
), lenA
);
141 expected_len
= MultiByteToWideChar(1252, 0, stringA
, lenA
, NULL
, 0);
142 ok(lenW
== expected_len
, "expected lenW %u, got %u\n", expected_len
, lenW
);
144 memset(bufW
, 'x', sizeof(bufW
));
145 lenA
= lstrlenA(stringA
);
146 lenW
= sizeof(bufW
)/sizeof(bufW
[0]);
147 ret
= pConvertINetMultiByteToUnicode(NULL
, 1252, stringA
, (INT
*)&lenA
, NULL
, (INT
*)&lenW
);
148 ok(ret
== S_OK
, "ConvertINetMultiByteToUnicode failed: %08x\n", ret
);
149 ok(lenA
== lstrlenA(stringA
), "expected lenA %u, got %u\n", lstrlenA(stringA
), lenA
);
150 expected_len
= MultiByteToWideChar(1252, 0, stringA
, lenA
, NULL
, 0);
151 ok(lenW
== expected_len
, "expected lenW %u, got %u\n", expected_len
, lenW
);
153 memset(bufW
, 'x', sizeof(bufW
));
154 lenA
= lstrlenA(stringA
);
156 ret
= pConvertINetMultiByteToUnicode(NULL
, 1252, stringA
, (INT
*)&lenA
, NULL
, (INT
*)&lenW
);
157 ok(ret
== S_OK
, "ConvertINetMultiByteToUnicode failed: %08x\n", ret
);
158 ok(lenA
== lstrlenA(stringA
), "expected lenA %u, got %u\n", lstrlenA(stringA
), lenA
);
159 expected_len
= MultiByteToWideChar(1252, 0, stringA
, lenA
, NULL
, 0);
160 ok(lenW
== expected_len
, "expected lenW %u, got %u\n", expected_len
, lenW
);
162 /* IMultiLanguage2_ConvertStringFromUnicode tests */
164 memset(bufA
, 'x', sizeof(bufA
));
167 ret
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, stringW
, &lenW
, bufA
, &lenA
);
168 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringFromUnicode failed: %08x\n", ret
);
169 ok(lenA
== 0, "expected lenA 0, got %u\n", lenA
);
170 ok(lenW
== 0, "expected lenW 0, got %u\n", lenW
);
172 memset(bufA
, 'x', sizeof(bufA
));
175 ret
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, stringW
, &lenW
, bufA
, &lenA
);
176 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringFromUnicode failed: %08x\n", ret
);
177 ok(lenA
== lstrlenA(stringA
), "expected lenA %u, got %u\n", lstrlenA(stringA
), lenA
);
178 ok(lenW
== lstrlenW(stringW
), "expected lenW %u, got %u\n", lstrlenW(stringW
), lenW
);
179 ok(bufA
[lenA
] != 0, "buf should not be 0 terminated\n");
180 bufA
[lenA
] = 0; /* -1 doesn't include 0 terminator */
181 ok(!lstrcmpA(bufA
, stringA
), "bufA/stringA mismatch\n");
183 memset(bufA
, 'x', sizeof(bufA
));
186 ret
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, stringW
, &lenW
, bufA
, &lenA
);
187 ok(ret
== E_FAIL
, "IMultiLanguage2_ConvertStringFromUnicode should fail: %08x\n", ret
);
188 ok(lenA
== 0, "expected lenA 0, got %u\n", lenA
);
189 /* still has to do partial conversion */
190 ok(!memcmp(bufA
, stringA
, 5), "bufW/stringW mismatch\n");
192 memset(bufA
, 'x', sizeof(bufA
));
195 ret
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, CP_UNICODE
, stringW
, &lenW
, bufA
, &lenA
);
196 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringFromUnicode failed: %08x\n", ret
);
197 ok(lenA
== lstrlenA(stringA
) * (int)sizeof(WCHAR
), "wrong lenA %u\n", lenA
);
198 ok(lenW
== lstrlenW(stringW
), "expected lenW %u, got %u\n", lstrlenW(stringW
), lenW
);
199 ok(bufA
[lenA
] != 0 && bufA
[lenA
+1] != 0, "buf should not be 0 terminated\n");
200 bufA
[lenA
] = 0; /* -1 doesn't include 0 terminator */
201 bufA
[lenA
+1] = 0; /* sizeof(WCHAR) */
202 ok(!lstrcmpW((LPCWSTR
)bufA
, stringW
), "bufA/stringW mismatch\n");
204 memset(bufA
, 'x', sizeof(bufA
));
205 lenW
= lstrlenW(stringW
);
207 ret
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, stringW
, &lenW
, NULL
, &lenA
);
208 ok(ret
== S_OK
, "IMultiLanguage2_ConvertStringFromUnicode failed: %08x\n", ret
);
209 ok(lenW
== lstrlenW(stringW
), "expected lenW %u, got %u\n", lstrlenW(stringW
), lenW
);
210 expected_len
= WideCharToMultiByte(1252, 0, stringW
, lenW
, NULL
, 0, NULL
, NULL
);
211 ok(lenA
== expected_len
, "expected lenA %u, got %u\n", expected_len
, lenA
);
214 static inline void cpinfo_cmp(MIMECPINFO
*cpinfo1
, MIMECPINFO
*cpinfo2
)
216 ok(cpinfo1
->dwFlags
== cpinfo2
->dwFlags
, "dwFlags mismatch: %08x != %08x\n", cpinfo1
->dwFlags
, cpinfo2
->dwFlags
);
217 ok(cpinfo1
->uiCodePage
== cpinfo2
->uiCodePage
, "uiCodePage mismatch: %u != %u\n", cpinfo1
->uiCodePage
, cpinfo2
->uiCodePage
);
218 ok(cpinfo1
->uiFamilyCodePage
== cpinfo2
->uiFamilyCodePage
, "uiFamilyCodePage mismatch: %u != %u\n", cpinfo1
->uiFamilyCodePage
, cpinfo2
->uiFamilyCodePage
);
219 ok(!lstrcmpW(cpinfo1
->wszDescription
, cpinfo2
->wszDescription
), "wszDescription mismatch\n");
220 ok(!lstrcmpW(cpinfo1
->wszWebCharset
, cpinfo2
->wszWebCharset
), "wszWebCharset mismatch\n");
221 ok(!lstrcmpW(cpinfo1
->wszHeaderCharset
, cpinfo2
->wszHeaderCharset
), "wszHeaderCharset mismatch\n");
222 ok(!lstrcmpW(cpinfo1
->wszBodyCharset
, cpinfo2
->wszBodyCharset
), "wszBodyCharset mismatch\n");
223 ok(!lstrcmpW(cpinfo1
->wszFixedWidthFont
, cpinfo2
->wszFixedWidthFont
), "wszFixedWidthFont mismatch\n");
224 ok(!lstrcmpW(cpinfo1
->wszProportionalFont
, cpinfo2
->wszProportionalFont
), "wszProportionalFont mismatch\n");
225 ok(cpinfo1
->bGDICharset
== cpinfo2
->bGDICharset
, "bGDICharset mismatch: %d != %d\n", cpinfo1
->bGDICharset
, cpinfo2
->bGDICharset
);
229 static const char *dump_mime_flags(DWORD flags
)
231 static char buf
[1024];
235 if (flags
& MIMECONTF_MAILNEWS
) strcat(buf
, " MIMECONTF_MAILNEWS");
236 if (flags
& MIMECONTF_BROWSER
) strcat(buf
, " MIMECONTF_BROWSER");
237 if (flags
& MIMECONTF_MINIMAL
) strcat(buf
, " MIMECONTF_MINIMAL");
238 if (flags
& MIMECONTF_IMPORT
) strcat(buf
, " MIMECONTF_IMPORT");
239 if (flags
& MIMECONTF_SAVABLE_MAILNEWS
) strcat(buf
, " MIMECONTF_SAVABLE_MAILNEWS");
240 if (flags
& MIMECONTF_SAVABLE_BROWSER
) strcat(buf
, " MIMECONTF_SAVABLE_BROWSER");
241 if (flags
& MIMECONTF_EXPORT
) strcat(buf
, " MIMECONTF_EXPORT");
242 if (flags
& MIMECONTF_PRIVCONVERTER
) strcat(buf
, " MIMECONTF_PRIVCONVERTER");
243 if (flags
& MIMECONTF_VALID
) strcat(buf
, " MIMECONTF_VALID");
244 if (flags
& MIMECONTF_VALID_NLS
) strcat(buf
, " MIMECONTF_VALID_NLS");
245 if (flags
& MIMECONTF_MIME_IE4
) strcat(buf
, " MIMECONTF_MIME_IE4");
246 if (flags
& MIMECONTF_MIME_LATEST
) strcat(buf
, " MIMECONTF_MIME_LATEST");
247 if (flags
& MIMECONTF_MIME_REGISTRY
) strcat(buf
, " MIMECONTF_MIME_REGISTRY");
253 static HRESULT
check_convertible(IMultiLanguage2
*iML2
, UINT from
, UINT to
)
255 CHAR convert
[MAX_PATH
];
260 static WCHAR strW
[] = {'a','b','c',0};
262 /* Check to see if the target codepage has these characters or not */
268 cb
= WideCharToMultiByte( from
, WC_NO_BEST_FIT_CHARS
| WC_COMPOSITECHECK
| WC_DEFAULTCHAR
,
269 strW
, 3, ch
, sizeof(ch
), NULL
, &fDefaultChar
);
271 if(cb
== 0 || fDefaultChar
)
273 trace("target codepage %i does not contain 'abc'\n",from
);
278 srcsz
= lstrlenW(strW
) + 1;
280 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, from
, strW
,
281 &srcsz
, convert
, &destsz
);
287 hr
= IMultiLanguage2_ConvertString(iML2
, NULL
, from
, to
, (BYTE
*)convert
,
288 &srcsz
, dest
, &destsz
);
295 static void test_EnumCodePages(IMultiLanguage2
*iML2
, DWORD flags
)
297 IEnumCodePage
*iEnumCP
= NULL
;
305 ret
= IMultiLanguage2_GetNumberOfCodePageInfo(iML2
, &total
);
306 ok(ret
== S_OK
&& total
!= 0, "IMultiLanguage2_GetNumberOfCodePageInfo: expected S_OK/!0, got %08x/%u\n", ret
, total
);
308 trace("total mlang supported codepages %u\n", total
);
310 ret
= IMultiLanguage2_EnumCodePages(iML2
, flags
, LANG_NEUTRAL
, &iEnumCP
);
311 ok(ret
== S_OK
&& iEnumCP
, "IMultiLanguage2_EnumCodePages: expected S_OK/!NULL, got %08x/%p\n", ret
, iEnumCP
);
313 ret
= IEnumCodePage_Reset(iEnumCP
);
314 ok(ret
== S_OK
, "IEnumCodePage_Reset: expected S_OK, got %08x\n", ret
);
316 ret
= IEnumCodePage_Next(iEnumCP
, 0, NULL
, &n
);
318 ok(n
== 0 && ret
== S_FALSE
, "IEnumCodePage_Next: expected 0/S_FALSE, got %u/%08x\n", n
, ret
);
319 else if (ret
== E_FAIL
)
320 ok(n
== 65536 && ret
== E_FAIL
, "IEnumCodePage_Next: expected 65536/E_FAIL, got %u/%08x\n", n
, ret
);
321 ret
= IEnumCodePage_Next(iEnumCP
, 0, NULL
, NULL
);
323 ok(ret
== S_FALSE
, "IEnumCodePage_Next: expected S_FALSE, got %08x\n", ret
);
324 else if (ret
== E_FAIL
)
325 ok(n
== 65536 && ret
== E_FAIL
, "IEnumCodePage_Next: expected 65536/E_FAIL, got %u/%08x\n", n
, ret
);
327 cpinfo
= HeapAlloc(GetProcessHeap(), 0, sizeof(*cpinfo
) * total
* 2);
330 ret
= IEnumCodePage_Next(iEnumCP
, 0, cpinfo
, &n
);
331 ok(ret
== S_FALSE
&& n
== 0, "IEnumCodePage_Next: expected S_FALSE/0, got %08x/%u\n", ret
, n
);
334 ret
= IEnumCodePage_Next(iEnumCP
, n
, cpinfo
, &n
);
335 ok(ret
== S_OK
&& n
!= 0, "IEnumCodePage_Next: expected S_OK/!0, got %08x/%u\n", ret
, n
);
337 trace("flags %08x, enumerated codepages %u\n", flags
, n
);
341 ok(n
== total
, "IEnumCodePage_Next: expected %u, got %u\n", total
, n
);
343 flags
= MIMECONTF_MIME_LATEST
;
348 for (i
= 0; i
< n
; i
++)
352 HRESULT convertible
= S_OK
;
353 static const WCHAR autoW
[] = {'_','a','u','t','o',0};
354 static const WCHAR feffW
[] = {'u','n','i','c','o','d','e','F','E','F','F',0};
357 trace("MIMECPINFO #%u:\n"
360 "uiFamilyCodePage %u\n"
361 "wszDescription %s\n"
363 "wszHeaderCharset %s\n"
364 "wszBodyCharset %s\n"
365 "wszFixedWidthFont %s\n"
366 "wszProportionalFont %s\n"
367 "bGDICharset %d\n\n",
369 cpinfo
[i
].dwFlags
, dump_mime_flags(cpinfo
[i
].dwFlags
),
370 cpinfo
[i
].uiCodePage
,
371 cpinfo
[i
].uiFamilyCodePage
,
372 wine_dbgstr_w(cpinfo
[i
].wszDescription
),
373 wine_dbgstr_w(cpinfo
[i
].wszWebCharset
),
374 wine_dbgstr_w(cpinfo
[i
].wszHeaderCharset
),
375 wine_dbgstr_w(cpinfo
[i
].wszBodyCharset
),
376 wine_dbgstr_w(cpinfo
[i
].wszFixedWidthFont
),
377 wine_dbgstr_w(cpinfo
[i
].wszProportionalFont
),
378 cpinfo
[i
].bGDICharset
);
380 ok(cpinfo
[i
].dwFlags
& flags
, "enumerated flags %08x do not include requested %08x\n", cpinfo
[i
].dwFlags
, flags
);
382 if (TranslateCharsetInfo((DWORD
*)(INT_PTR
)cpinfo
[i
].uiFamilyCodePage
, &csi
, TCI_SRCCODEPAGE
))
383 ok(cpinfo
[i
].bGDICharset
== csi
.ciCharset
, "%d != %d\n", cpinfo
[i
].bGDICharset
, csi
.ciCharset
);
385 trace("TranslateCharsetInfo failed for cp %u\n", cpinfo
[i
].uiFamilyCodePage
);
388 trace("%u: codepage %u family %u\n", i
, cpinfo
[i
].uiCodePage
, cpinfo
[i
].uiFamilyCodePage
);
390 /* Win95 does not support UTF-7 */
391 if (cpinfo
[i
].uiCodePage
== CP_UTF7
) continue;
393 /* support files for some codepages might be not installed, or
394 * the codepage is just an alias.
396 if (IsValidCodePage(cpinfo
[i
].uiCodePage
))
398 ret
= IMultiLanguage2_IsConvertible(iML2
, cpinfo
[i
].uiCodePage
, CP_UNICODE
);
399 ok(ret
== S_OK
, "IMultiLanguage2_IsConvertible(%u -> CP_UNICODE) = %08x\n", cpinfo
[i
].uiCodePage
, ret
);
400 ret
= IMultiLanguage2_IsConvertible(iML2
, CP_UNICODE
, cpinfo
[i
].uiCodePage
);
401 ok(ret
== S_OK
, "IMultiLanguage2_IsConvertible(CP_UNICODE -> %u) = %08x\n", cpinfo
[i
].uiCodePage
, ret
);
403 convertible
= check_convertible(iML2
, cpinfo
[i
].uiCodePage
, CP_UTF8
);
404 if (convertible
!= E_FAIL
)
406 ret
= IMultiLanguage2_IsConvertible(iML2
, cpinfo
[i
].uiCodePage
, CP_UTF8
);
407 ok(ret
== convertible
, "IMultiLanguage2_IsConvertible(%u -> CP_UTF8) = %08x\n", cpinfo
[i
].uiCodePage
, ret
);
408 ret
= IMultiLanguage2_IsConvertible(iML2
, CP_UTF8
, cpinfo
[i
].uiCodePage
);
409 ok(ret
== convertible
, "IMultiLanguage2_IsConvertible(CP_UTF8 -> %u) = %08x\n", cpinfo
[i
].uiCodePage
, ret
);
413 trace("IsValidCodePage failed for cp %u\n", cpinfo
[i
].uiCodePage
);
415 if (memcmp(cpinfo
[i
].wszWebCharset
,feffW
,sizeof(WCHAR
)*11)==0)
416 skip("Legacy windows bug returning invalid charset of unicodeFEFF\n");
419 ret
= IMultiLanguage2_GetCharsetInfo(iML2
, cpinfo
[i
].wszWebCharset
, &mcsi
);
420 /* _autoxxx charsets are a fake and GetCharsetInfo fails for them */
421 if (memcmp(cpinfo
[i
].wszWebCharset
, autoW
, 5 * sizeof(WCHAR
)))
423 ok (ret
== S_OK
, "IMultiLanguage2_GetCharsetInfo failed: %08x\n", ret
);
425 trace("%s: %u %u %s\n", wine_dbgstr_w(cpinfo
[i
].wszWebCharset
), mcsi
.uiCodePage
, mcsi
.uiInternetEncoding
, wine_dbgstr_w(mcsi
.wszCharset
));
427 ok(!lstrcmpiW(cpinfo
[i
].wszWebCharset
, mcsi
.wszCharset
),
430 wine_dbgstr_w(cpinfo
[i
].wszWebCharset
), wine_dbgstr_w(mcsi
.wszCharset
));
432 "wszWebCharset mismatch\n");
437 /* native mlang returns completely messed up encodings in some cases */
438 ok(mcsi
.uiInternetEncoding
== cpinfo
[i
].uiCodePage
|| mcsi
.uiInternetEncoding
== cpinfo
[i
].uiFamilyCodePage
,
439 "%u != %u || %u\n", mcsi
.uiInternetEncoding
, cpinfo
[i
].uiCodePage
, cpinfo
[i
].uiFamilyCodePage
);
440 ok(mcsi
.uiCodePage
== cpinfo
[i
].uiCodePage
|| mcsi
.uiCodePage
== cpinfo
[i
].uiFamilyCodePage
,
441 "%u != %u || %u\n", mcsi
.uiCodePage
, cpinfo
[i
].uiCodePage
, cpinfo
[i
].uiFamilyCodePage
);
446 if (memcmp(cpinfo
[i
].wszHeaderCharset
,feffW
,sizeof(WCHAR
)*11)==0)
447 skip("Legacy windows bug returning invalid charset of unicodeFEFF\n");
450 ret
= IMultiLanguage2_GetCharsetInfo(iML2
, cpinfo
[i
].wszHeaderCharset
, &mcsi
);
451 /* _autoxxx charsets are a fake and GetCharsetInfo fails for them */
452 if (memcmp(cpinfo
[i
].wszHeaderCharset
, autoW
, 5 * sizeof(WCHAR
)))
454 ok (ret
== S_OK
, "IMultiLanguage2_GetCharsetInfo failed: %08x\n", ret
);
456 trace("%s: %u %u %s\n", wine_dbgstr_w(cpinfo
[i
].wszHeaderCharset
), mcsi
.uiCodePage
, mcsi
.uiInternetEncoding
, wine_dbgstr_w(mcsi
.wszCharset
));
458 ok(!lstrcmpiW(cpinfo
[i
].wszHeaderCharset
, mcsi
.wszCharset
),
461 wine_dbgstr_w(cpinfo
[i
].wszHeaderCharset
), wine_dbgstr_w(mcsi
.wszCharset
));
463 "wszHeaderCharset mismatch\n");
468 /* native mlang returns completely messed up encodings in some cases */
469 ok(mcsi
.uiInternetEncoding
== cpinfo
[i
].uiCodePage
|| mcsi
.uiInternetEncoding
== cpinfo
[i
].uiFamilyCodePage
,
470 "%u != %u || %u\n", mcsi
.uiInternetEncoding
, cpinfo
[i
].uiCodePage
, cpinfo
[i
].uiFamilyCodePage
);
471 ok(mcsi
.uiCodePage
== cpinfo
[i
].uiCodePage
|| mcsi
.uiCodePage
== cpinfo
[i
].uiFamilyCodePage
,
472 "%u != %u || %u\n", mcsi
.uiCodePage
, cpinfo
[i
].uiCodePage
, cpinfo
[i
].uiFamilyCodePage
);
477 if (memcmp(cpinfo
[i
].wszBodyCharset
,feffW
,sizeof(WCHAR
)*11)==0)
478 skip("Legacy windows bug returning invalid charset of unicodeFEFF\n");
481 ret
= IMultiLanguage2_GetCharsetInfo(iML2
, cpinfo
[i
].wszBodyCharset
, &mcsi
);
482 /* _autoxxx charsets are a fake and GetCharsetInfo fails for them */
483 if (memcmp(cpinfo
[i
].wszBodyCharset
, autoW
, 5 * sizeof(WCHAR
)))
485 ok (ret
== S_OK
, "IMultiLanguage2_GetCharsetInfo failed: %08x\n", ret
);
487 trace("%s: %u %u %s\n", wine_dbgstr_w(cpinfo
[i
].wszBodyCharset
), mcsi
.uiCodePage
, mcsi
.uiInternetEncoding
, wine_dbgstr_w(mcsi
.wszCharset
));
489 ok(!lstrcmpiW(cpinfo
[i
].wszBodyCharset
, mcsi
.wszCharset
),
492 wine_dbgstr_w(cpinfo
[i
].wszBodyCharset
), wine_dbgstr_w(mcsi
.wszCharset
));
494 "wszBodyCharset mismatch\n");
499 /* native mlang returns completely messed up encodings in some cases */
500 ok(mcsi
.uiInternetEncoding
== cpinfo
[i
].uiCodePage
|| mcsi
.uiInternetEncoding
== cpinfo
[i
].uiFamilyCodePage
,
501 "%u != %u || %u\n", mcsi
.uiInternetEncoding
, cpinfo
[i
].uiCodePage
, cpinfo
[i
].uiFamilyCodePage
);
502 ok(mcsi
.uiCodePage
== cpinfo
[i
].uiCodePage
|| mcsi
.uiCodePage
== cpinfo
[i
].uiFamilyCodePage
,
503 "%u != %u || %u\n", mcsi
.uiCodePage
, cpinfo
[i
].uiCodePage
, cpinfo
[i
].uiFamilyCodePage
);
509 /* now IEnumCodePage_Next should fail, since pointer is at the end */
511 ret
= IEnumCodePage_Next(iEnumCP
, 1, &cpinfo2
, &n
);
512 ok(ret
== S_FALSE
&& n
== 0, "IEnumCodePage_Next: expected S_FALSE/0, got %08x/%u\n", ret
, n
);
514 ret
= IEnumCodePage_Reset(iEnumCP
);
515 ok(ret
== S_OK
, "IEnumCodePage_Reset: expected S_OK, got %08x\n", ret
);
517 ret
= IEnumCodePage_Next(iEnumCP
, 1, &cpinfo2
, &n
);
518 ok(n
== 1 && ret
== S_OK
, "IEnumCodePage_Next: expected 1/S_OK, got %u/%08x\n", n
, ret
);
519 cpinfo_cmp(&cpinfo
[0], &cpinfo2
);
523 /* Due to a bug in MS' implementation of IEnumCodePage_Skip
524 * it's not used here.
526 ret
= IEnumCodePage_Skip(iEnumCP
, 1);
527 ok(ret
== S_OK
, "IEnumCodePage_Skip: expected S_OK, got %08x\n", ret
);
529 for (i
= 0; i
< total
- 1; i
++)
532 ret
= IEnumCodePage_Next(iEnumCP
, 1, &cpinfo2
, &n
);
533 ok(n
== 1 && ret
== S_OK
, "IEnumCodePage_Next: expected 1/S_OK, got %u/%08x\n", n
, ret
);
534 cpinfo_cmp(&cpinfo
[i
+ 1], &cpinfo2
);
537 HeapFree(GetProcessHeap(), 0, cpinfo
);
538 IEnumCodePage_Release(iEnumCP
);
541 static inline void scriptinfo_cmp(SCRIPTINFO
*sinfo1
, SCRIPTINFO
*sinfo2
)
543 ok(sinfo1
->ScriptId
== sinfo2
->ScriptId
, "ScriptId mismatch: %d != %d\n", sinfo1
->ScriptId
, sinfo2
->ScriptId
);
544 ok(sinfo1
->uiCodePage
== sinfo2
->uiCodePage
, "uiCodePage mismatch: %u != %u\n", sinfo1
->uiCodePage
, sinfo2
->uiCodePage
);
545 ok(!lstrcmpW(sinfo1
->wszDescription
, sinfo2
->wszDescription
), "wszDescription mismatch\n");
546 ok(!lstrcmpW(sinfo1
->wszFixedWidthFont
, sinfo2
->wszFixedWidthFont
), "wszFixedWidthFont mismatch\n");
547 ok(!lstrcmpW(sinfo1
->wszProportionalFont
, sinfo2
->wszProportionalFont
), "wszProportionalFont mismatch\n");
550 static void test_EnumScripts(IMultiLanguage2
*iML2
, DWORD flags
)
552 IEnumScript
*iEnumScript
= NULL
;
560 ret
= IMultiLanguage2_GetNumberOfScripts(iML2
, &total
);
561 ok(ret
== S_OK
&& total
!= 0, "IMultiLanguage2_GetNumberOfScripts: expected S_OK/!0, got %08x/%u\n", ret
, total
);
563 trace("total mlang supported scripts %u\n", total
);
565 ret
= IMultiLanguage2_EnumScripts(iML2
, flags
, LANG_NEUTRAL
, &iEnumScript
);
566 ok(ret
== S_OK
&& iEnumScript
, "IMultiLanguage2_EnumScripts: expected S_OK/!NULL, got %08x/%p\n", ret
, iEnumScript
);
568 ret
= IEnumScript_Reset(iEnumScript
);
569 ok(ret
== S_OK
, "IEnumScript_Reset: expected S_OK, got %08x\n", ret
);
571 ret
= IEnumScript_Next(iEnumScript
, 0, NULL
, &n
);
572 ok(n
== 65536 && ret
== E_FAIL
, "IEnumScript_Next: expected 65536/E_FAIL, got %u/%08x\n", n
, ret
);
573 ret
= IEnumScript_Next(iEnumScript
, 0, NULL
, NULL
);
574 ok(ret
== E_FAIL
, "IEnumScript_Next: expected E_FAIL, got %08x\n", ret
);
576 sinfo
= HeapAlloc(GetProcessHeap(), 0, sizeof(*sinfo
) * total
* 2);
579 ret
= IEnumScript_Next(iEnumScript
, 0, sinfo
, &n
);
580 ok(ret
== S_FALSE
&& n
== 0, "IEnumScript_Next: expected S_FALSE/0, got %08x/%u\n", ret
, n
);
583 ret
= IEnumScript_Next(iEnumScript
, n
, sinfo
, &n
);
584 ok(ret
== S_OK
&& n
!= 0, "IEnumScript_Next: expected S_OK, got %08x/%u\n", ret
, n
);
586 trace("flags %08x, enumerated scripts %u\n", flags
, n
);
590 ok(n
== total
, "IEnumScript_Next: expected %u, got %u\n", total
, n
);
591 flags
= SCRIPTCONTF_SCRIPT_USER
| SCRIPTCONTF_SCRIPT_HIDE
| SCRIPTCONTF_SCRIPT_SYSTEM
;
596 for (i
= 0; pGetCPInfoExA
&& i
< n
; i
++)
598 #ifdef DUMP_SCRIPT_INFO
599 trace("SCRIPTINFO #%u:\n"
602 "wszDescription %s\n"
603 "wszFixedWidthFont %s\n"
604 "wszProportionalFont %s\n\n",
608 wine_dbgstr_w(sinfo
[i
].wszDescription
),
609 wine_dbgstr_w(sinfo
[i
].wszFixedWidthFont
),
610 wine_dbgstr_w(sinfo
[i
].wszProportionalFont
));
611 trace("%u codepage %u\n", i
, sinfo
[i
].uiCodePage
);
615 /* now IEnumScript_Next should fail, since pointer is at the end */
617 ret
= IEnumScript_Next(iEnumScript
, 1, &sinfo2
, &n
);
618 ok(ret
== S_FALSE
&& n
== 0, "IEnumScript_Next: expected S_FALSE/0, got %08x/%u\n", ret
, n
);
620 ret
= IEnumScript_Reset(iEnumScript
);
621 ok(ret
== S_OK
, "IEnumScript_Reset: expected S_OK, got %08x\n", ret
);
623 ret
= IEnumScript_Next(iEnumScript
, 1, &sinfo2
, &n
);
624 ok(n
== 1 && ret
== S_OK
, "IEnumScript_Next: expected 1/S_OK, got %u/%08x\n", n
, ret
);
625 scriptinfo_cmp(&sinfo
[0], &sinfo2
);
629 /* Due to a bug in MS' implementation of IEnumScript_Skip
630 * it's not used here.
632 ret
= IEnumScript_Skip(iEnumScript
, 1);
633 ok(ret
== S_OK
, "IEnumScript_Skip: expected S_OK, got %08x\n", ret
);
635 for (i
= 0; i
< total
- 1; i
++)
638 ret
= IEnumScript_Next(iEnumScript
, 1, &sinfo2
, &n
);
639 ok(n
== 1 && ret
== S_OK
, "IEnumScript_Next: expected 1/S_OK, got %u/%08x\n", n
, ret
);
640 scriptinfo_cmp(&sinfo
[i
+ 1], &sinfo2
);
643 HeapFree(GetProcessHeap(), 0, sinfo
);
644 IEnumScript_Release(iEnumScript
);
647 static void IMLangFontLink_Test(IMLangFontLink
* iMLFL
)
649 DWORD dwCodePages
, dwManyCodePages
;
650 DWORD dwCmpCodePages
;
655 ret
= IMLangFontLink_CodePageToCodePages(iMLFL
, -1, &dwCodePages
);
656 ok(ret
== E_FAIL
, "IMLangFontLink_CodePageToCodePages should fail: %x\n", ret
);
657 ok(dwCodePages
== 0, "expected 0, got %u\n", dwCodePages
);
660 ret
= IMLangFontLink_CodePageToCodePages(iMLFL
, 932, &dwCodePages
);
661 ok(ret
== S_OK
, "IMLangFontLink_CodePageToCodePages error %x\n", ret
);
662 ok(dwCodePages
== FS_JISJAPAN
, "expected FS_JISJAPAN, got %08x\n", dwCodePages
);
664 ret
= IMLangFontLink_CodePagesToCodePage(iMLFL
, dwCodePages
, 1035, &CodePage
);
665 ok(ret
== S_OK
, "IMLangFontLink_CodePagesToCodePage error %x\n", ret
);
666 ok(CodePage
== 932, "Incorrect CodePage Returned (%i)\n",CodePage
);
669 ret
= IMLangFontLink_CodePageToCodePages(iMLFL
, 1252, &dwManyCodePages
);
670 ok(ret
== S_OK
, "IMLangFontLink_CodePageToCodePages error %x\n", ret
);
671 ok(dwManyCodePages
== FS_LATIN1
, "expected FS_LATIN1, got %08x\n", dwManyCodePages
);
673 ret
= IMLangFontLink_CodePageToCodePages(iMLFL
, 1256, &dwCodePages
);
674 ok(ret
== S_OK
, "IMLangFontLink_CodePageToCodePages error %x\n", ret
);
675 ok(dwCodePages
== FS_ARABIC
, "expected FS_ARABIC, got %08x\n", dwCodePages
);
676 dwManyCodePages
|= dwCodePages
;
677 ret
= IMLangFontLink_CodePageToCodePages(iMLFL
, 874, &dwCodePages
);
678 ok(ret
== S_OK
, "IMLangFontLink_CodePageToCodePages error %x\n", ret
);
679 ok(dwCodePages
== FS_THAI
, "expected FS_THAI, got %08x\n", dwCodePages
);
680 dwManyCodePages
|= dwCodePages
;
682 ret
= IMLangFontLink_CodePagesToCodePage(iMLFL
, dwManyCodePages
, 1256, &CodePage
);
683 ok(ret
== S_OK
, "IMLangFontLink_CodePagesToCodePage error %x\n", ret
);
684 ok(CodePage
== 1256, "Incorrect CodePage Returned (%i)\n",CodePage
);
686 ret
= IMLangFontLink_CodePagesToCodePage(iMLFL
, dwManyCodePages
, 936, &CodePage
);
687 ok(ret
== S_OK
, "IMLangFontLink_CodePagesToCodePage error %x\n", ret
);
688 ok(CodePage
== 1252, "Incorrect CodePage Returned (%i)\n",CodePage
);
690 /* Tests for GetCharCodePages */
693 dwCmpCodePages
= FS_LATIN1
| FS_LATIN2
| FS_CYRILLIC
| FS_GREEK
| FS_TURKISH
694 | FS_HEBREW
| FS_ARABIC
| FS_BALTIC
| FS_VIETNAMESE
| FS_THAI
695 | FS_JISJAPAN
| FS_CHINESESIMP
| FS_WANSUNG
| FS_CHINESETRAD
;
696 ok(IMLangFontLink_GetCharCodePages(iMLFL
, 'd', &dwCodePages
) == S_OK
,
697 "IMLangFontLink_GetCharCodePages failed\n");
698 ok(dwCodePages
== dwCmpCodePages
, "Incorrect CodePages returned (%i)\n", dwCodePages
);
701 dwCmpCodePages
= FS_CYRILLIC
| FS_JISJAPAN
| FS_CHINESESIMP
| FS_WANSUNG
;
702 ok(IMLangFontLink_GetCharCodePages(iMLFL
, 0x0436, &dwCodePages
) == S_OK
,
703 "IMLangFontLink_GetCharCodePages failed\n");
704 ok(dwCodePages
== dwCmpCodePages
, "Incorrect CodePages returned (%i)\n", dwCodePages
);
707 dwCmpCodePages
= FS_JISJAPAN
;
708 ok(IMLangFontLink_GetCharCodePages(iMLFL
, 0xff90, &dwCodePages
) == S_OK
,
709 "IMLangFontLink_GetCharCodePages failed\n");
710 ok(dwCodePages
== dwCmpCodePages
, "Incorrect CodePages returned (%i)\n", dwCodePages
);
713 /* copied from libs/wine/string.c */
714 static WCHAR
*strstrW(const WCHAR
*str
, const WCHAR
*sub
)
718 const WCHAR
*p1
= str
, *p2
= sub
;
719 while (*p1
&& *p2
&& *p1
== *p2
) { p1
++; p2
++; }
720 if (!*p2
) return (WCHAR
*)str
;
726 static void test_rfc1766(IMultiLanguage2
*iML2
)
728 IEnumRfc1766
*pEnumRfc1766
;
734 ret
= IMultiLanguage2_EnumRfc1766(iML2
, LANG_NEUTRAL
, &pEnumRfc1766
);
735 ok(ret
== S_OK
, "IMultiLanguage2_EnumRfc1766 error %08x\n", ret
);
739 ret
= IEnumRfc1766_Next(pEnumRfc1766
, 1, &info
, &n
);
740 if (ret
!= S_OK
) break;
743 trace("lcid %04x rfc_name %s locale_name %s\n",
744 info
.lcid
, wine_dbgstr_w(info
.wszRfc1766
), wine_dbgstr_w(info
.wszLocaleName
));
747 ok(n
== 1, "couldn't fetch 1 RFC1766INFO structure\n");
749 /* verify the Rfc1766 value */
750 ret
= IMultiLanguage2_GetRfc1766FromLcid(iML2
, info
.lcid
, &rfcstr
);
751 ok(ret
== S_OK
, "Expected S_OK, got %08x\n", ret
);
753 /* not an exact 1:1 correspondence between lcid and rfc1766 in the
754 * mlang database, e.g., nb-no -> 1044 -> no */
755 ok(strstrW(info
.wszRfc1766
, rfcstr
) != NULL
,
756 "Expected matching locale names\n");
758 SysFreeString(rfcstr
);
760 IEnumRfc1766_Release(pEnumRfc1766
);
763 static void test_GetLcidFromRfc1766(IMultiLanguage2
*iML2
)
768 static WCHAR e
[] = { 'e',0 };
769 static WCHAR en
[] = { 'e','n',0 };
770 static WCHAR empty
[] = { 0 };
771 static WCHAR dash
[] = { '-',0 };
772 static WCHAR e_dash
[] = { 'e','-',0 };
773 static WCHAR en_gb
[] = { 'e','n','-','g','b',0 };
774 static WCHAR en_us
[] = { 'e','n','-','u','s',0 };
775 static WCHAR en_them
[] = { 'e','n','-','t','h','e','m',0 };
776 static WCHAR english
[] = { 'e','n','g','l','i','s','h',0 };
778 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, NULL
, en
);
779 ok(ret
== E_INVALIDARG
, "GetLcidFromRfc1766 returned: %08x\n", ret
);
781 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, &lcid
, NULL
);
782 ok(ret
== E_INVALIDARG
, "GetLcidFromRfc1766 returned: %08x\n", ret
);
784 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, &lcid
, e
);
785 ok(ret
== E_FAIL
, "GetLcidFromRfc1766 returned: %08x\n", ret
);
787 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, &lcid
, empty
);
788 ok(ret
== E_FAIL
, "GetLcidFromRfc1766 returned: %08x\n", ret
);
790 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, &lcid
, dash
);
791 ok(ret
== E_FAIL
, "GetLcidFromRfc1766 returned: %08x\n", ret
);
793 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, &lcid
, e_dash
);
794 ok(ret
== E_FAIL
, "GetLcidFromRfc1766 returned: %08x\n", ret
);
796 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, &lcid
, en_them
);
797 ok((ret
== E_FAIL
|| ret
== S_FALSE
), "GetLcidFromRfc1766 returned: %08x\n", ret
);
801 static WCHAR en
[] = {'e','n',0};
803 ret
= IMultiLanguage2_GetRfc1766FromLcid(iML2
, lcid
, &rfcstr
);
804 ok(ret
== S_OK
, "Expected S_OK, got %08x\n", ret
);
805 ok_w2("Expected \"%s\", got \"%s\"n", en
, rfcstr
);
808 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, &lcid
, english
);
809 ok((ret
== E_FAIL
|| ret
== S_FALSE
), "GetLcidFromRfc1766 returned: %08x\n", ret
);
813 static WCHAR en
[] = {'e','n',0};
815 ret
= IMultiLanguage2_GetRfc1766FromLcid(iML2
, lcid
, &rfcstr
);
816 ok(ret
== S_OK
, "Expected S_OK, got %08x\n", ret
);
817 ok_w2("Expected \"%s\", got \"%s\"n", en
, rfcstr
);
822 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, &lcid
, en
);
823 ok(ret
== S_OK
, "GetLcidFromRfc1766 returned: %08x\n", ret
);
824 ok(lcid
== 9, "got wrong lcid: %04x\n", lcid
);
826 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, &lcid
, en_gb
);
827 ok(ret
== S_OK
, "GetLcidFromRfc1766 returned: %08x\n", ret
);
828 ok(lcid
== 0x809, "got wrong lcid: %04x\n", lcid
);
830 ret
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, &lcid
, en_us
);
831 ok(ret
== S_OK
, "GetLcidFromRfc1766 returned: %08x\n", ret
);
832 ok(lcid
== 0x409, "got wrong lcid: %04x\n", lcid
);
835 static void test_GetRfc1766FromLcid(IMultiLanguage2
*iML2
)
841 static WCHAR kok
[] = {'k','o','k',0};
843 hr
= IMultiLanguage2_GetLcidFromRfc1766(iML2
, &lcid
, kok
);
845 * S_FALSE happens when 'kok' instead matches to a different Rfc1766 name
846 * for example 'ko' so it is not a failure but does not give us what
851 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
853 hr
= IMultiLanguage2_GetRfc1766FromLcid(iML2
, lcid
, &rfcstr
);
854 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
855 ok_w2("Expected \"%s\", got \"%s\"n", kok
, rfcstr
);
856 SysFreeString(rfcstr
);
860 static void test_IMultiLanguage2_ConvertStringFromUnicode(IMultiLanguage2
*iML2
)
863 CHAR invariate
[MAX_PATH
];
867 static WCHAR src
[] = {'a','b','c',0};
869 memset(invariate
, 'x', sizeof(invariate
));
872 memset(dest
, 'x', sizeof(dest
));
873 srcsz
= lstrlenW(src
) + 1;
874 destsz
= sizeof(dest
);
875 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, NULL
,
876 &srcsz
, dest
, &destsz
);
877 ok(hr
== S_OK
|| hr
== E_FAIL
,"expected S_OK or E_FAIL, got %08x\n",hr
);
880 ok(srcsz
== lstrlenW(src
) + 1,
881 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
883 else if (hr
== E_FAIL
)
886 "Expected %u, got %u\n", 0, srcsz
);
889 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
890 "Expected dest to be unchanged, got %s\n", dest
);
891 ok(destsz
== 0, "Expected 0, got %u\n", destsz
);
894 memset(dest
, 'x', sizeof(dest
));
895 destsz
= sizeof(dest
);
896 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
897 NULL
, dest
, &destsz
);
898 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
899 ok(!strncmp(dest
, "abc", 3),
900 "Expected first three chars to be \"abc\"\n");
901 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
902 "Expected rest of dest to be unchanged, got %s\n", dest
);
903 ok(destsz
== lstrlenW(src
),
904 "Expected %u, got %u\n", lstrlenW(src
), destsz
);
906 /* both pSrcStr and pcSrcSize NULL */
907 memset(dest
, 'x', sizeof(dest
));
908 destsz
= sizeof(dest
);
909 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, NULL
,
910 NULL
, dest
, &destsz
);
911 ok(hr
== S_OK
|| hr
== E_FAIL
, "Expected S_OK or E_FAIL, got %08x\n", hr
);
912 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
913 "Expected dest to be unchanged, got %s\n", dest
);
914 ok(destsz
== 0, "Expected 0, got %u\n", destsz
);
917 memset(dest
, 'x', sizeof(dest
));
918 srcsz
= lstrlenW(src
) + 1;
919 destsz
= sizeof(dest
);
920 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
921 &srcsz
, NULL
, &destsz
);
922 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
923 ok(srcsz
== lstrlenW(src
) + 1,
924 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
925 ok(destsz
== lstrlenW(src
) + 1,
926 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
929 memset(dest
, 'x', sizeof(dest
));
930 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
932 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
933 ok(srcsz
== lstrlenW(src
) + 1,
934 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
935 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
936 "Expected dest to be unchanged, got %s\n", dest
);
939 memset(dest
, 'x', sizeof(dest
));
941 destsz
= sizeof(dest
);
942 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
943 &srcsz
, dest
, &destsz
);
944 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
945 ok(srcsz
== 0, "Expected 0, got %u\n", srcsz
);
946 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
947 "Expected dest to be unchanged, got %s\n", dest
);
948 ok(destsz
== 0, "Expected 0, got %u\n", destsz
);
950 /* pcSrcSize does not include NULL terminator */
951 memset(dest
, 'x', sizeof(dest
));
952 srcsz
= lstrlenW(src
);
953 destsz
= sizeof(dest
);
954 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
955 &srcsz
, dest
, &destsz
);
956 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
957 ok(srcsz
== lstrlenW(src
),
958 "Expected %u, got %u\n", lstrlenW(src
), srcsz
);
959 ok(!strncmp(dest
, "abc", 3), "Expected first three chars to be \"abc\"\n");
960 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
961 "Expected rest of dest to be unchanged, got %s\n", dest
);
962 ok(destsz
== lstrlenW(src
),
963 "Expected %u, got %u\n", lstrlenW(src
), destsz
);
965 /* pcSrcSize includes NULL terminator */
966 memset(dest
, 'x', sizeof(dest
));
967 srcsz
= lstrlenW(src
) + 1;
968 destsz
= sizeof(dest
);
969 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
970 &srcsz
, dest
, &destsz
);
971 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
972 ok(srcsz
== lstrlenW(src
) + 1, "Expected 3, got %u\n", srcsz
);
973 ok(!lstrcmpA(dest
, "abc"), "Expected \"abc\", got \"%s\"\n", dest
);
974 ok(destsz
== lstrlenW(src
) + 1,
975 "Expected %u, got %u\n", lstrlenW(src
) + 1, destsz
);
977 /* pcSrcSize is -1 */
978 memset(dest
, 'x', sizeof(dest
));
980 destsz
= sizeof(dest
);
981 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
982 &srcsz
, dest
, &destsz
);
983 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
984 ok(srcsz
== lstrlenW(src
),
985 "Expected %u, got %u\n", lstrlenW(src
), srcsz
);
986 ok(!strncmp(dest
, "abc", 3), "Expected first three chars to be \"abc\"\n");
987 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
988 "Expected rest of dest to be unchanged, got %s\n", dest
);
989 ok(destsz
== lstrlenW(src
),
990 "Expected %u, got %u\n", lstrlenW(src
), destsz
);
993 memset(dest
, 'x', sizeof(dest
));
994 srcsz
= lstrlenW(src
) + 1;
996 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
997 &srcsz
, dest
, &destsz
);
998 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
999 ok(srcsz
== lstrlenW(src
) + 1,
1000 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1001 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1002 "Expected dest to be unchanged, got %s\n", dest
);
1003 ok(destsz
== lstrlenW(src
) + 1,
1004 "Expected %u, got %u\n", lstrlenW(src
) + 1, destsz
);
1006 /* pcDstSize is not large enough */
1007 memset(dest
, 'x', sizeof(dest
));
1008 srcsz
= lstrlenW(src
) + 1;
1009 destsz
= lstrlenW(src
);
1010 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
1011 &srcsz
, dest
, &destsz
);
1012 ok(hr
== E_FAIL
, "Expected E_FAIL, got %08x\n", hr
);
1013 ok(srcsz
== 0, "Expected 0, got %u\n", srcsz
);
1014 ok(!strncmp(dest
, "abc", 3), "Expected first three chars to be \"abc\"\n");
1015 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
1016 "Expected rest of dest to be unchanged, got %s\n", dest
);
1017 ok(destsz
== 0, "Expected 0, got %u\n", srcsz
);
1019 /* pcDstSize (bytes) does not leave room for NULL terminator */
1020 memset(dest
, 'x', sizeof(dest
));
1021 srcsz
= lstrlenW(src
) + 1;
1022 destsz
= lstrlenW(src
) * sizeof(WCHAR
);
1023 hr
= IMultiLanguage2_ConvertStringFromUnicode(iML2
, NULL
, 1252, src
,
1024 &srcsz
, dest
, &destsz
);
1025 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1026 ok(srcsz
== lstrlenW(src
) + 1,
1027 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1028 ok(!lstrcmpA(dest
, "abc"), "Expected \"abc\", got \"%s\"\n", dest
);
1029 ok(destsz
== lstrlenW(src
) + 1,
1030 "Expected %u, got %u\n", lstrlenW(src
) + 1, destsz
);
1033 static void test_ConvertINetUnicodeToMultiByte(void)
1035 CHAR dest
[MAX_PATH
];
1036 CHAR invariate
[MAX_PATH
];
1040 static WCHAR src
[] = {'a','b','c',0};
1042 memset(invariate
, 'x', sizeof(invariate
));
1045 memset(dest
, 'x', sizeof(dest
));
1046 srcsz
= lstrlenW(src
) + 1;
1047 destsz
= sizeof(dest
);
1048 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, NULL
, &srcsz
, dest
, &destsz
);
1049 ok(hr
== S_OK
|| hr
== E_FAIL
, "Expected S_OK or E_FAIL, got %08x\n", hr
);
1051 ok(srcsz
== lstrlenW(src
) + 1,
1052 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1053 else if (hr
== E_FAIL
)
1055 "Expected %u, got %u\n", 0, srcsz
);
1056 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1057 "Expected dest to be unchanged, got %s\n", dest
);
1058 ok(destsz
== 0, "Expected 0, got %u\n", destsz
);
1060 /* lpnWideCharCount NULL */
1061 memset(dest
, 'x', sizeof(dest
));
1062 destsz
= sizeof(dest
);
1063 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, NULL
, dest
, &destsz
);
1064 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1065 ok(!strncmp(dest
, "abc", 3),
1066 "Expected first three chars to be \"abc\"\n");
1067 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
1068 "Expected rest of dest to be unchanged, got %s\n", dest
);
1069 ok(destsz
== lstrlenW(src
),
1070 "Expected %u, got %u\n", lstrlenW(src
), destsz
);
1072 /* both lpSrcStr and lpnWideCharCount NULL */
1073 memset(dest
, 'x', sizeof(dest
));
1074 destsz
= sizeof(dest
);
1075 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, NULL
, NULL
, dest
, &destsz
);
1076 ok(hr
== S_OK
|| hr
== E_FAIL
, "Expected S_OK or E_FAIL, got %08x\n", hr
);
1077 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1078 "Expected dest to be unchanged, got %s\n", dest
);
1079 ok(destsz
== 0, "Expected 0, got %u\n", destsz
);
1082 memset(dest
, 'x', sizeof(dest
));
1083 srcsz
= lstrlenW(src
) + 1;
1084 destsz
= sizeof(dest
);
1085 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, NULL
, &destsz
);
1086 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1087 ok(srcsz
== lstrlenW(src
) + 1,
1088 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1089 ok(destsz
== lstrlenW(src
) + 1,
1090 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1092 /* lpnMultiCharCount NULL */
1093 memset(dest
, 'x', sizeof(dest
));
1094 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, NULL
);
1095 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1096 ok(srcsz
== lstrlenW(src
) + 1,
1097 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1098 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1099 "Expected dest to be unchanged, got %s\n", dest
);
1101 /* lpnWideCharCount is 0 */
1102 memset(dest
, 'x', sizeof(dest
));
1104 destsz
= sizeof(dest
);
1105 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, &destsz
);
1106 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1107 ok(srcsz
== 0, "Expected 0, got %u\n", srcsz
);
1108 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1109 "Expected dest to be unchanged, got %s\n", dest
);
1110 ok(destsz
== 0, "Expected 0, got %u\n", destsz
);
1112 /* lpnWideCharCount does not include NULL terminator */
1113 memset(dest
, 'x', sizeof(dest
));
1114 srcsz
= lstrlenW(src
);
1115 destsz
= sizeof(dest
);
1116 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, &destsz
);
1117 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1118 ok(srcsz
== lstrlenW(src
),
1119 "Expected %u, got %u\n", lstrlenW(src
), srcsz
);
1120 ok(!strncmp(dest
, "abc", 3), "Expected first three chars to be \"abc\"\n");
1121 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
1122 "Expected rest of dest to be unchanged, got %s\n", dest
);
1123 ok(destsz
== lstrlenW(src
),
1124 "Expected %u, got %u\n", lstrlenW(src
), destsz
);
1126 /* lpnWideCharCount includes NULL terminator */
1127 memset(dest
, 'x', sizeof(dest
));
1128 srcsz
= lstrlenW(src
) + 1;
1129 destsz
= sizeof(dest
);
1130 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, &destsz
);
1131 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1132 ok(srcsz
== lstrlenW(src
) + 1, "Expected 3, got %u\n", srcsz
);
1133 ok(!lstrcmpA(dest
, "abc"), "Expected \"abc\", got \"%s\"\n", dest
);
1134 ok(destsz
== lstrlenW(src
) + 1,
1135 "Expected %u, got %u\n", lstrlenW(src
) + 1, destsz
);
1137 /* lpnWideCharCount is -1 */
1138 memset(dest
, 'x', sizeof(dest
));
1140 destsz
= sizeof(dest
);
1141 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, &destsz
);
1142 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1143 ok(srcsz
== lstrlenW(src
),
1144 "Expected %u, got %u\n", lstrlenW(src
), srcsz
);
1145 ok(!strncmp(dest
, "abc", 3), "Expected first three chars to be \"abc\"\n");
1146 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
1147 "Expected rest of dest to be unchanged, got %s\n", dest
);
1148 ok(destsz
== lstrlenW(src
),
1149 "Expected %u, got %u\n", lstrlenW(src
), destsz
);
1151 /* lpnMultiCharCount is 0 */
1152 memset(dest
, 'x', sizeof(dest
));
1153 srcsz
= lstrlenW(src
) + 1;
1155 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, &destsz
);
1156 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1157 ok(srcsz
== lstrlenW(src
) + 1,
1158 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1159 ok(!memcmp(dest
, invariate
, sizeof(dest
)),
1160 "Expected dest to be unchanged, got %s\n", dest
);
1161 ok(destsz
== lstrlenW(src
) + 1,
1162 "Expected %u, got %u\n", lstrlenW(src
) + 1, destsz
);
1164 /* lpnMultiCharCount is not large enough */
1165 memset(dest
, 'x', sizeof(dest
));
1166 srcsz
= lstrlenW(src
) + 1;
1167 destsz
= lstrlenW(src
);
1168 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, &destsz
);
1169 ok(hr
== E_FAIL
, "Expected E_FAIL, got %08x\n", hr
);
1170 ok(srcsz
== 0, "Expected 0, got %u\n", srcsz
);
1171 ok(!strncmp(dest
, "abc", 3), "Expected first three chars to be \"abc\"\n");
1172 ok(!memcmp(&dest
[3], invariate
, sizeof(dest
) - 3),
1173 "Expected rest of dest to be unchanged, got %s\n", dest
);
1174 ok(destsz
== 0, "Expected 0, got %u\n", srcsz
);
1176 /* lpnMultiCharCount (bytes) does not leave room for NULL terminator */
1177 memset(dest
, 'x', sizeof(dest
));
1178 srcsz
= lstrlenW(src
) + 1;
1179 destsz
= lstrlenW(src
) * sizeof(WCHAR
);
1180 hr
= pConvertINetUnicodeToMultiByte(NULL
, 1252, src
, &srcsz
, dest
, &destsz
);
1181 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1182 ok(srcsz
== lstrlenW(src
) + 1,
1183 "Expected %u, got %u\n", lstrlenW(src
) + 1, srcsz
);
1184 ok(!lstrcmpA(dest
, "abc"), "Expected \"abc\", got \"%s\"\n", dest
);
1185 ok(destsz
== lstrlenW(src
) + 1,
1186 "Expected %u, got %u\n", lstrlenW(src
) + 1, destsz
);
1189 static void test_JapaneseConversion(void)
1192 static WCHAR unc_jp
[9][12] = {
1193 {9,0x31,0x20,0x3042,0x3044,0x3046,0x3048,0x304a,0x000d,0x000a},
1194 {9,0x31,0x20,0x30a2,0x30a4,0x30a6,0x30a8,0x30aa,0x000d,0x000a},
1195 {9,0x31,0x20,0xff71,0xff72,0xff73,0xff74,0xff75,0x000d,0x000a},
1196 {9,0x31,0x20,0x3041,0x3043,0x3045,0x3047,0x3049,0x000d,0x000a},
1197 {9,0x31,0x20,0x30a1,0x30a3,0x30a5,0x30a7,0x30a9,0x000d,0x000a},
1198 {9,0x31,0x20,0xff67,0xff68,0xff69,0xff6a,0xff6b,0x000d,0x000a},
1199 {9,0x31,0x20,0x300c,0x65e5,0x672c,0x8a9e,0x300d,0x000d,0x000a},
1200 {7,0x31,0x20,0x25c7,0x25c7,0x3012,0x000d,0x000a},
1201 {11,0x31,0x20,0x203b,0x3010,0x0074,0x0065,0x0073,0x0074,0x3011,0x000d,0x000a}
1203 static CHAR jis_jp
[9][27] = {
1204 {20,0x31,0x20,0x1b,0x24,0x42,0x24,0x22,0x24,0x24,0x24,0x26,0x24,0x28,
1205 0x24,0x2a,0x1b,0x28,0x42,0x0d,0x0a},
1206 {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x22,0x25,0x24,0x25,0x26,0x25,0x28,
1207 0x25,0x2a,0x1b,0x28,0x42,0x0d,0x0a},
1208 {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x22,0x25,0x24,0x25,0x26,0x25,0x28,
1209 0x25,0x2a,0x1b,0x28,0x42,0x0d,0x0a},
1210 {20,0x31,0x20,0x1b,0x24,0x42,0x24,0x21,0x24,0x23,0x24,0x25,0x24,0x27,
1211 0x24,0x29,0x1b,0x28,0x42,0x0d,0x0a},
1212 {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x21,0x25,0x23,0x25,0x25,0x25,0x27,
1213 0x25,0x29,0x1b,0x28,0x42,0x0d,0x0a},
1214 {20,0x31,0x20,0x1b,0x24,0x42,0x25,0x21,0x25,0x23,0x25,0x25,0x25,0x27,
1215 0x25,0x29,0x1b,0x28,0x42,0x0d,0x0a},
1216 {20,0x31,0x20,0x1b,0x24,0x42,0x21,0x56,0x46,0x7c,0x4b,0x5c,0x38,0x6c,
1217 0x21,0x57,0x1b,0x28,0x42,0x0d,0x0a},
1218 {16,0x31,0x20,0x1b,0x24,0x42,0x21,0x7e,0x21,0x7e,0x22,0x29,0x1b,0x28,
1220 {26,0x31,0x20,0x1b,0x24,0x42,0x22,0x28,0x21,0x5a,0x1b,0x28,0x42,0x74,
1221 0x65,0x73,0x74,0x1b,0x24,0x42,0x21,0x5b,0x1b,0x28,0x42,0x0d,0x0a}
1223 static CHAR sjis_jp
[9][15] = {
1224 {14,0x31,0x20,0x82,0xa0,0x82,0xa2,0x82,0xa4,0x82,0xa6,0x82,0xa8,0x0d,0x0a},
1225 {14,0x31,0x20,0x83,0x41,0x83,0x43,0x83,0x45,0x83,0x47,0x83,0x49,0x0d,0x0a},
1226 {9,0x31,0x20,0xb1,0xb2,0xb3,0xb4,0xb5,0x0d,0x0a},
1227 {14,0x31,0x20,0x82,0x9f,0x82,0xa1,0x82,0xa3,0x82,0xa5,0x82,0xa7,0x0d,0x0a},
1228 {14,0x31,0x20,0x83,0x40,0x83,0x42,0x83,0x44,0x83,0x46,0x83,0x48,0x0d,0x0a},
1229 {9,0x31,0x20,0xa7,0xa8,0xa9,0xaa,0xab,0x0d,0x0a},
1230 {14,0x31,0x20,0x81,0x75,0x93,0xfa,0x96,0x7b,0x8c,0xea,0x81,0x76,0x0d,0x0a},
1231 {10,0x31,0x20,0x81,0x9e,0x81,0x9e,0x81,0xa7,0x0d,0x0a},
1232 {14,0x31,0x20,0x81,0xa6,0x81,0x79,0x74,0x65,0x73,0x74,0x81,0x7a,0x0d,0x0a}
1234 static CHAR euc_jp
[9][15] = {
1235 {14,0x31,0x20,0xa4,0xa2,0xa4,0xa4,0xa4,0xa6,0xa4,0xa8,0xa4,0xaa,0x0d,0x0a},
1236 {14,0x31,0x20,0xa5,0xa2,0xa5,0xa4,0xa5,0xa6,0xa5,0xa8,0xa5,0xaa,0x0d,0x0a},
1237 {14,0x31,0x20,0x8e,0xb1,0x8e,0xb2,0x8e,0xb3,0x8e,0xb4,0x8e,0xb5,0x0d,0x0a},
1238 {14,0x31,0x20,0xa4,0xa1,0xa4,0xa3,0xa4,0xa5,0xa4,0xa7,0xa4,0xa9,0x0d,0x0a},
1239 {14,0x31,0x20,0xa5,0xa1,0xa5,0xa3,0xa5,0xa5,0xa5,0xa7,0xa5,0xa9,0x0d,0x0a},
1240 {14,0x31,0x20,0x8e,0xa7,0x8e,0xa8,0x8e,0xa9,0x8e,0xaa,0x8e,0xab,0x0d,0x0a},
1241 {14,0x31,0x20,0xa1,0xd6,0xc6,0xfc,0xcb,0xdc,0xb8,0xec,0xa1,0xd7,0x0d,0x0a},
1242 {10,0x31,0x20,0xa1,0xfe,0xa1,0xfe,0xa2,0xa9,0x0d,0x0a},
1243 {14,0x31,0x20,0xa2,0xa8,0xa1,0xda,0x74,0x65,0x73,0x74,0xa1,0xdb,0x0d,0x0a}
1254 for (i
= 0; i
< 9; i
++)
1258 outlen
= jis_jp
[i
][0];
1259 srcsz
= unc_jp
[i
][0];
1260 hr
= pConvertINetUnicodeToMultiByte(NULL
, 50220, &unc_jp
[i
][1], &srcsz
, output
, &destsz
);
1263 skip("Code page identifier 50220 is not supported\n");
1266 ok(hr
== S_OK
,"(%i) Expected S_OK, got %08x\n", i
, hr
);
1267 ok(destsz
== outlen
, "(%i) Expected %i, got %i\n",i
,outlen
,destsz
);
1268 ok(srcsz
== unc_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[i
][0],srcsz
);
1269 ok(memcmp(output
,&jis_jp
[i
][1],destsz
)==0,"(%i) Strings do not match\n",i
);
1274 hr
= pConvertINetMultiByteToUnicode(NULL
, 50220, output
, &srcsz
, outputW
,&destsz
);
1277 * JIS does not have hankata so it get automatically converted to
1278 * zenkata. this means that strings 1 and 2 are identical as well as
1285 ok(hr
== S_OK
,"(%i) Expected S_OK, got %08x\n",i
, hr
);
1286 ok(destsz
== unc_jp
[j
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[j
][0],destsz
);
1287 ok(srcsz
== outlen
,"(%i) Expected %i, got %i\n",i
,outlen
,srcsz
);
1288 ok(memcmp(outputW
,&unc_jp
[j
][1],destsz
)==0,"(%i) Strings do not match\n",i
);
1291 /* test unc->sjis */
1292 for (i
= 0; i
< 9; i
++)
1295 outlen
= sjis_jp
[i
][0];
1296 srcsz
= unc_jp
[i
][0];
1298 hr
= pConvertINetUnicodeToMultiByte(NULL
, 932, &unc_jp
[i
][1], &srcsz
, output
, &destsz
);
1301 skip("Code page identifier 932 is not supported\n");
1304 ok(hr
== S_OK
,"(%i) Expected S_OK, got %08x\n",i
,hr
);
1305 ok(destsz
== outlen
,"(%i) Expected %i, got %i\n",i
,outlen
,destsz
);
1306 ok(srcsz
== unc_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[i
][0],srcsz
);
1307 ok(memcmp(output
,&sjis_jp
[i
][1],outlen
)==0,"(%i) Strings do not match\n",i
);
1311 hr
= pConvertINetMultiByteToUnicode(NULL
, 932, output
, &srcsz
, outputW
,&destsz
);
1313 ok(hr
== S_OK
,"(%i) Expected S_OK, got %08x\n", i
, hr
);
1314 ok(destsz
== unc_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[i
][0],destsz
);
1315 ok(srcsz
== outlen
,"(%i) Expected %i, got %i\n",i
,outlen
,srcsz
);
1316 ok(memcmp(outputW
,&unc_jp
[i
][1],destsz
)==0,"(%i) Strings do not match\n",i
);
1320 for (i
= 0; i
< 9; i
++)
1323 outlen
= euc_jp
[i
][0];
1324 srcsz
= unc_jp
[i
][0];
1326 hr
= pConvertINetUnicodeToMultiByte(NULL
, 51932, &unc_jp
[i
][1], &srcsz
, output
, &destsz
);
1329 skip("Code page identifier 51932 is not supported\n");
1332 ok(hr
== S_OK
, "(%i) Expected S_OK, got %08x\n",i
,hr
);
1333 ok(destsz
== outlen
, "(%i) Expected %i, got %i\n",i
,outlen
,destsz
);
1334 ok(srcsz
== unc_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[i
][0],destsz
);
1335 ok(memcmp(output
,&euc_jp
[i
][1],outlen
)==0,"(%i) Strings do not match\n",i
);
1339 hr
= pConvertINetMultiByteToUnicode(NULL
, 51932, output
, &srcsz
, outputW
,&destsz
);
1341 ok(hr
== S_OK
,"(%i) Expected S_OK, got %08x\n",i
,hr
);
1342 ok(destsz
== unc_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[i
][0],destsz
);
1343 ok(srcsz
== outlen
,"(%i) Expected %i, got %i\n",i
,outlen
,srcsz
);
1344 ok(memcmp(outputW
,&unc_jp
[i
][1],destsz
)==0,"(%i) Strings do not match\n",i
);
1347 /* Japanese autodetect */
1350 srcsz
= jis_jp
[i
][0];
1351 hr
= pConvertINetMultiByteToUnicode(NULL
, 50932, &jis_jp
[i
][1], &srcsz
, outputW
, &destsz
);
1354 skip("Code page identifier 50932 is not supported\n");
1357 ok(hr
== S_OK
,"(%i) Expected S_OK, got %08x\n",i
,hr
);
1358 ok(destsz
== unc_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[i
][0],destsz
);
1359 ok(srcsz
== jis_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,jis_jp
[i
][0],srcsz
);
1360 ok(memcmp(outputW
,&unc_jp
[i
][1],destsz
)==0,"(%i) Strings do not match\n",i
);
1364 srcsz
= sjis_jp
[i
][0];
1365 hr
= pConvertINetMultiByteToUnicode(NULL
, 50932, &sjis_jp
[i
][1], &srcsz
, outputW
, &destsz
);
1366 ok(hr
== S_OK
,"(%i) Expected S_OK, got %08x\n",i
,hr
);
1367 ok(destsz
== unc_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,unc_jp
[i
][0],destsz
);
1368 ok(srcsz
== sjis_jp
[i
][0],"(%i) Expected %i, got %i\n",i
,sjis_jp
[i
][0],srcsz
);
1369 ok(memcmp(outputW
,&unc_jp
[i
][1],destsz
)==0,"(%i) Strings do not match\n",i
);
1374 IMultiLanguage2
*iML2
= NULL
;
1375 IMLangFontLink
*iMLFL
= NULL
;
1378 if (!init_function_ptrs())
1382 ret
= CoCreateInstance(&CLSID_CMultiLanguage
, NULL
, CLSCTX_INPROC_SERVER
,
1383 &IID_IMultiLanguage2
, (void **)&iML2
);
1384 if (ret
!= S_OK
|| !iML2
) return;
1387 test_GetLcidFromRfc1766(iML2
);
1388 test_GetRfc1766FromLcid(iML2
);
1390 test_EnumCodePages(iML2
, 0);
1391 test_EnumCodePages(iML2
, MIMECONTF_MIME_LATEST
);
1392 test_EnumCodePages(iML2
, MIMECONTF_BROWSER
);
1393 test_EnumCodePages(iML2
, MIMECONTF_MINIMAL
);
1394 test_EnumCodePages(iML2
, MIMECONTF_VALID
);
1395 /* FIXME: why MIMECONTF_MIME_REGISTRY returns 0 of supported codepages? */
1396 /*test_EnumCodePages(iML2, MIMECONTF_MIME_REGISTRY);*/
1398 test_EnumScripts(iML2
, 0);
1399 test_EnumScripts(iML2
, SCRIPTCONTF_SCRIPT_USER
);
1400 test_EnumScripts(iML2
, SCRIPTCONTF_SCRIPT_USER
| SCRIPTCONTF_SCRIPT_HIDE
| SCRIPTCONTF_SCRIPT_SYSTEM
);
1402 ret
= IMultiLanguage2_IsConvertible(iML2
, CP_UTF8
, CP_UNICODE
);
1403 ok(ret
== S_OK
, "IMultiLanguage2_IsConvertible(CP_UTF8 -> CP_UNICODE) = %08x\n", ret
);
1404 ret
= IMultiLanguage2_IsConvertible(iML2
, CP_UNICODE
, CP_UTF8
);
1405 ok(ret
== S_OK
, "IMultiLanguage2_IsConvertible(CP_UNICODE -> CP_UTF8) = %08x\n", ret
);
1407 test_multibyte_to_unicode_translations(iML2
);
1408 test_IMultiLanguage2_ConvertStringFromUnicode(iML2
);
1410 IMultiLanguage2_Release(iML2
);
1412 test_ConvertINetUnicodeToMultiByte();
1414 test_JapaneseConversion();
1416 ret
= CoCreateInstance(&CLSID_CMultiLanguage
, NULL
, CLSCTX_INPROC_SERVER
,
1417 &IID_IMLangFontLink
, (void **)&iMLFL
);
1418 if (ret
!= S_OK
|| !iML2
) return;
1420 IMLangFontLink_Test(iMLFL
);
1421 IMLangFontLink_Release(iMLFL
);