Commit 3861c1e3 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Add support for multi-byte characters in _mbctolower_l.

parent cbcbaf36
......@@ -451,12 +451,34 @@ unsigned int CDECL _mbsnextc(const unsigned char* str)
*/
unsigned int CDECL _mbctolower_l(unsigned int c, _locale_t locale)
{
if (_ismbblead_l(c, locale))
unsigned char str[2], ret[2];
pthreadmbcinfo mbcinfo;
if(!locale)
mbcinfo = get_mbcinfo();
else
mbcinfo = locale->mbcinfo;
if (c > 0xff)
{
FIXME("Handle MBC chars\n");
return c;
if (!_ismbblead_l((c >> 8) & 0xff, locale))
return c;
str[0] = c >> 8;
str[1] = c;
switch(__crtLCMapStringA(mbcinfo->mblcid, LCMAP_LOWERCASE,
(char*)str, 2, (char*)ret, 2, mbcinfo->mbcodepage, 0))
{
case 0:
return c;
case 1:
return ret[0];
default:
return ret[1] + (ret[0] << 8);
}
}
return _tolower_l(c, locale); /* ASCII CP or SB char */
return mbcinfo->mbctype[c + 1] & _SBUP ? mbcinfo->mbcasemap[c] : c;
}
/*********************************************************************
......
......@@ -2896,6 +2896,7 @@ static void test__mbslwr_s(void)
{
errno_t ret;
unsigned char buffer[20];
int cp = _getmbcp();
if (!p_mbslwr_s)
{
......@@ -2946,6 +2947,14 @@ static void test__mbslwr_s(void)
ok(!memcmp(buffer, "abcdefgh\0IJKLMNOP", sizeof("abcdefgh\0IJKLMNOP")),
"Expected the output buffer to be \"abcdefgh\\0IJKLMNOP\", got \"%s\"\n",
buffer);
_setmbcp(936);
memcpy(buffer, "\xa2\xf1\xa2\xf2Q", sizeof("\xa2\xf1\xa2\xf2Q"));
ret = p_mbslwr_s(buffer, sizeof(buffer));
ok(ret == 0, "Expected _mbsupr_s to return 0, got %d\n", ret);
ok(!memcmp(buffer, "\xa2\xa1\xa2\xa2q", sizeof("\xa2\xa1\xa2\xa2q")),
"got %s\n", debugstr_a((char*)buffer));
_setmbcp(cp);
}
static void test__mbstok(void)
......
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