22#define NONAMELESSUNION
39 IMimeInternational *internat, *internat2;
49 if(internat == internat2)
53 ref = IMimeInternational_Release(internat2);
58 ref = IMimeInternational_Release(internat);
63 ref = IMimeInternational_Release(internat2);
66 ref = IMimeInternational_Release(internat);
74 return CoCreateInstance(&CLSID_CMultiLanguage,
NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
75 &IID_IMultiLanguage, (
void **)ml);
91 hr = IMultiLanguage_GetCharsetInfo(ml, bstr, mlang_info);
92 IMultiLanguage_Release(ml);
108 hr = IMultiLanguage_GetCodePageInfo(ml,
cp, mlang_cp_info);
109 IMultiLanguage_Release(ml);
116 MIMECPINFO mlang_cp_info;
127 charset_name = mlang_cp_info.wszBodyCharset;
130 charset_name = mlang_cp_info.wszHeaderCharset;
133 charset_name = mlang_cp_info.wszWebCharset;
141 hr = IMultiLanguage_GetCharsetInfo(ml, charset_name, mlang_info);
142 IMultiLanguage_Release(ml);
149 IMimeInternational *internat;
151 HCHARSET hcs, hcs_windows_1252, hcs_windows_1251;
152 INETCSETINFO cs_info;
153 MIMECSETINFO mlang_cs_info;
158 hr = IMimeInternational_FindCharset(internat,
"nonexistent", &hcs);
159 ok(
hr == MIME_E_NOT_FOUND,
"got %08x\n",
hr);
161 hr = IMimeInternational_FindCharset(internat,
"windows-1252", &hcs_windows_1252);
163 hr = IMimeInternational_FindCharset(internat,
"windows-1252", &hcs);
165 ok(hcs_windows_1252 == hcs,
"got different hcharsets for the same name\n");
166 hr = IMimeInternational_FindCharset(internat,
"WiNdoWs-1252", &hcs);
168 ok(hcs_windows_1252 == hcs,
"got different hcharsets for the same name\n");
170 hr = IMimeInternational_FindCharset(internat,
"windows-1251", &hcs_windows_1251);
172 ok(hcs_windows_1252 != hcs_windows_1251,
"got the same hcharset for the different names\n");
174 hr = IMimeInternational_GetCharsetInfo(internat, hcs_windows_1252, &cs_info);
179 ok(cs_info.cpiWindows == mlang_cs_info.uiCodePage,
"cpiWindows %d while mlang uiCodePage %d\n",
180 cs_info.cpiWindows, mlang_cs_info.uiCodePage);
181 ok(cs_info.cpiInternet == mlang_cs_info.uiInternetEncoding,
"cpiInternet %d while mlang uiInternetEncoding %d\n",
182 cs_info.cpiInternet, mlang_cs_info.uiInternetEncoding);
183 ok(cs_info.hCharset == hcs_windows_1252,
"hCharset doesn't match requested\n");
184 ok(!
strcmp(cs_info.szName,
"windows-1252"),
"szName doesn't match requested\n");
186 hr = IMimeInternational_GetCodePageCharset(internat, 1252, CHARSET_BODY, &hcs);
188 hr = IMimeInternational_GetCharsetInfo(internat, hcs, &cs_info);
193 ok(cs_info.cpiWindows == mlang_cs_info.uiCodePage,
"cpiWindows %d while mlang uiCodePage %d\n",
194 cs_info.cpiWindows, mlang_cs_info.uiCodePage);
195 ok(cs_info.cpiInternet == mlang_cs_info.uiInternetEncoding,
"cpiInternet %d while mlang uiInternetEncoding %d\n",
196 cs_info.cpiInternet, mlang_cs_info.uiInternetEncoding);
198 IMimeInternational_Release(internat);
203 IMimeInternational *internat;
205 HCHARSET hcs_default, hcs, hcs_windows_1251;
210 hr = IMimeInternational_GetDefaultCharset(internat, &hcs_default);
212 hr = IMimeInternational_GetCodePageCharset(internat,
GetACP(), CHARSET_BODY, &hcs);
214 ok(hcs_default == hcs,
"Unexpected default charset\n");
216 hr = IMimeInternational_FindCharset(internat,
"windows-1251", &hcs_windows_1251);
218 hr = IMimeInternational_SetDefaultCharset(internat, hcs_windows_1251);
220 hr = IMimeInternational_GetDefaultCharset(internat, &hcs);
222 ok(hcs == hcs_windows_1251,
"didn't retrieve recently set default\n");
224 hr = IMimeInternational_SetDefaultCharset(internat, hcs_default);
227 IMimeInternational_Release(internat);
232 IMimeInternational *internat;
236 PROPVARIANT prop_in, prop_out;
238 static WCHAR test_stringW[] = {
't',
'e',
's',
't',
' ',
's',
't',
'r',
'i',
'n',
'g',0};
245 hr = IMimeInternational_ConvertBuffer(internat, 1252, 28591, &
src, &
dst, &
read);
252 hr = IMimeInternational_ConvertBuffer(internat, 1252, 28591, &
src, &
dst, &
read);
255 ok(
dst.cbSize == 2,
"got %d\n",
dst.cbSize);
259 prop_in.u.pwszVal = test_stringW;
260 hr = IMimeInternational_ConvertString(internat,
CP_UNICODE, 1252, &prop_in, &prop_out);
262 ok(prop_out.vt ==
VT_LPSTR,
"got %d\n", prop_out.vt);
268 prop_in.u.pwszVal = test_stringW;
269 hr = IMimeInternational_ConvertString(internat, 28591, 1252, &prop_in, &prop_out);
271 ok(prop_out.vt ==
VT_LPSTR,
"got %d\n", prop_out.vt);
277 hr = IMimeInternational_ConvertString(internat, 28591,
CP_UNICODE, &prop_in, &prop_out);
279 ok(prop_out.vt ==
VT_LPWSTR,
"got %d\n", prop_out.vt);
280 ok(!
lstrcmpW(prop_out.u.pwszVal, test_stringW),
"mismatched strings\n");
288 ok(prop_out.vt ==
VT_LPWSTR,
"got %d\n", prop_out.vt);
289 ok(!
lstrcmpW(prop_out.u.pwszVal, test_stringW),
"mismatched strings\n");
292 IMimeInternational_Release(internat);
int strcmp(const char *String1, const char *String2)
#define MultiByteToWideChar
static HRESULT mlang_getcsetinfo(const char *charset, MIMECSETINFO *mlang_info)
HRESULT WINAPI MimeOleGetInternat(IMimeInternational **internat)
static HRESULT get_mlang(IMultiLanguage **ml)
static HRESULT mlang_getcodepageinfo(UINT cp, MIMECPINFO *mlang_cp_info)
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
HRESULT WINAPI PropVariantClear(PROPVARIANT *pvar)
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
VOID WINAPI CoTaskMemFree(LPVOID ptr)
static HRESULT mlang_getcsetinfo_from_cp(UINT cp, CHARSETTYPE charset_type, MIMECSETINFO *mlang_info)
static void test_create(void)
static void test_convert(void)
static void test_charset(void)
static void test_defaultcharset(void)
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)