mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-14 19:05:40 +00:00
msvcrt: Implement _mbcjistojms.
This commit is contained in:
parent
8052c1a230
commit
2254a549a6
|
@ -317,6 +317,42 @@ unsigned int CDECL _mbctoupper(unsigned int c)
|
|||
return toupper(c); /* ASCII CP or SB char */
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* _mbcjistojms(MSVCRT.@)
|
||||
*
|
||||
* Converts a jis character to sjis.
|
||||
* Based on description from
|
||||
* http://www.slayers.ne.jp/~oouchi/code/jistosjis.html
|
||||
*/
|
||||
unsigned int CDECL _mbcjistojms(unsigned int c)
|
||||
{
|
||||
/* Conversion takes place only when codepage is 932.
|
||||
In all other cases, c is returned unchanged */
|
||||
if(MSVCRT___lc_codepage == 932)
|
||||
{
|
||||
if(HIBYTE(c) >= 0x21 && HIBYTE(c) <= 0x7e &&
|
||||
LOBYTE(c) >= 0x21 && LOBYTE(c) <= 0x7e)
|
||||
{
|
||||
if(HIBYTE(c) % 2)
|
||||
c += 0x1f;
|
||||
else
|
||||
c += 0x7d;
|
||||
|
||||
if(LOBYTE(c) > 0x7F)
|
||||
c += 0x1;
|
||||
|
||||
c = (((HIBYTE(c) - 0x21)/2 + 0x81) << 8) | LOBYTE(c);
|
||||
|
||||
if(HIBYTE(c) > 0x9f)
|
||||
c += 0x4000;
|
||||
}
|
||||
else
|
||||
return 0; /* Codepage is 932, but c can't be converted */
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* _mbsdec(MSVCRT.@)
|
||||
*/
|
||||
|
|
|
@ -358,7 +358,7 @@
|
|||
@ cdecl _mbbtype(long long)
|
||||
# extern _mbcasemap
|
||||
@ cdecl _mbccpy (str str)
|
||||
@ stub _mbcjistojms #(long)
|
||||
@ cdecl _mbcjistojms (long)
|
||||
@ stub _mbcjmstojis #(long)
|
||||
@ cdecl _mbclen(ptr)
|
||||
@ stub _mbctohira #(long)
|
||||
|
|
|
@ -597,6 +597,28 @@ static void test_wcscpy_s(void)
|
|||
ok(szDestShort[0] == 0, "szDestShort[0] not 0\n");
|
||||
}
|
||||
|
||||
static void test_mbcjisjms(void)
|
||||
{
|
||||
/* List of value-pairs to test. The test assumes the last pair to be {0, ..} */
|
||||
unsigned int jisjms[][2] = { {0x2020, 0}, {0x2021, 0}, {0x2120, 0}, {0x2121, 0x8140},
|
||||
{0x7f7f, 0}, {0x7f7e, 0}, {0x7e7f, 0}, {0x7e7e, 0xeffc},
|
||||
{0x2121FFFF, 0}, {0x2223, 0x81a1}, {0x237e, 0x829e}, {0, 0}};
|
||||
unsigned int ret, exp, i;
|
||||
|
||||
i = 0;
|
||||
do
|
||||
{
|
||||
ret = _mbcjistojms(jisjms[i][0]);
|
||||
|
||||
if(_getmbcp() == 932) /* Japanese codepage? */
|
||||
exp = jisjms[i][1];
|
||||
else
|
||||
exp = jisjms[i][0]; /* If not, no conversion */
|
||||
|
||||
ok(ret == exp, "Expected 0x%x, got 0x%x\n", exp, ret);
|
||||
} while(jisjms[i++][0] != 0);
|
||||
}
|
||||
|
||||
START_TEST(string)
|
||||
{
|
||||
char mem[100];
|
||||
|
@ -637,6 +659,7 @@ START_TEST(string)
|
|||
test_strcpy_s();
|
||||
test_strcat_s();
|
||||
test__mbsnbcpy_s();
|
||||
test_mbcjisjms();
|
||||
|
||||
test_wcscpy_s();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue