Jactry Zeng <jzeng(a)codeweavers.com> wrote:
+static LPWSTR c2w(LPCSTR string) +{ + INT lenW; + LPWSTR stringW = NULL; + + if (!string) + return stringW; + + lenW = MultiByteToWideChar(1252, 0, string, -1, NULL, 0); + if ((stringW = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR)))) + MultiByteToWideChar(1252, 0, string, -1, stringW, lenW); + return stringW; +}
As mentioned before tis will break a lot of apps that write profile strings using system locale.
@@ -1189,7 +1272,11 @@ START_TEST(profile) "name2=\"val2\"\r\n" "name3\r\n" "name4=a\r\n" - "[section2]\r\n", + "[section2]\r\n" + "[\xe6\xae\xb5\x31]\r\n" /* Simplified Chinese in UTF-8 */ + "name5=\xe9\x85\x92\x2e\r\n" /* Simplified Chinese in UTF-8 */ + "\xe5\xa7\x93=\xe6\x9b\xbe\x2e\r\n" /* Simplified Chinese in UTF-8 */ + "name6=\xd7\x99\xd7\x99\xd7\x9f\x2e\r\n", /* Hebrew in UTF-8 */ "CR+LF"); test_GetPrivateProfileString( "[section1]\r" @@ -1197,7 +1284,11 @@ START_TEST(profile) "name2=\"val2\"\r" "name3\r" "name4=a\r" - "[section2]\r", + "[section2]\r" + "[\xe6\xae\xb5\x31]\r" /* Simplified Chinese in UTF-8 */ + "name5=\xe9\x85\x92\x2e\r" /* Simplified Chinese in UTF-8 */ + "\xe5\xa7\x93=\xe6\x9b\xbe\x2e\r" /* Simplified Chinese in UTF-8 */ + "name6=\xd7\x99\xd7\x99\xd7\x9f\x2e\r", /* Hebrew in UTF-8 */
Why are you testing with UTF-8 encoded strings but the implementation uses code page 1252? This is clearly broken. Please add the convincing set of the tests first to show the problem, at the moment I fail to see what exactly you are trying trying to fix, and only then try to think about the possible ways to fix the spotted bug(s). -- Dmitry.