msvcrt: Fix wctob in C locale.

oldstable
Akihiro Sagawa 2011-11-30 22:34:13 +09:00 committed by Alexandre Julliard
parent f9403bfb90
commit 13aff6dc56
2 changed files with 10 additions and 1 deletions

View File

@ -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);
}

View File

@ -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;
}