Commit 13aff6dc authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

msvcrt: Fix wctob in C locale.

parent f9403bfb
......@@ -2002,6 +2002,9 @@ static void test_wctob(void)
ret = p_wctob(0x81);
ok(ret == (int)(char)0x81, "ret = %x\n", ret);
ret = p_wctob(0x9f);
ok(ret == (int)(char)0x9f, "ret = %x\n", ret);
ret = p_wctob(0xe0);
ok(ret == (int)(char)0xe0, "ret = %x\n", ret);
}
......
......@@ -1056,8 +1056,14 @@ INT CDECL MSVCRT_wctob( MSVCRT_wint_t wchar )
{
char out;
BOOL error;
UINT codepage = get_locinfo()->lc_codepage;
if(WideCharToMultiByte( get_locinfo()->lc_codepage, 0, &wchar, 1, &out, 1, NULL, &error ) && !error)
if(!codepage) {
if (wchar < 0xff)
return (signed char)wchar;
else
return MSVCRT_EOF;
} else if(WideCharToMultiByte( codepage, 0, &wchar, 1, &out, 1, NULL, &error ) && !error)
return (INT)out;
return MSVCRT_EOF;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment