Commit 2254a549 authored by David Hedberg's avatar David Hedberg Committed by Alexandre Julliard

msvcrt: Implement _mbcjistojms.

parent 8052c1a2
...@@ -318,6 +318,42 @@ unsigned int CDECL _mbctoupper(unsigned int c) ...@@ -318,6 +318,42 @@ unsigned int CDECL _mbctoupper(unsigned int c)
} }
/********************************************************************* /*********************************************************************
* _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.@) * _mbsdec(MSVCRT.@)
*/ */
unsigned char* CDECL _mbsdec(const unsigned char* start, const unsigned char* cur) unsigned char* CDECL _mbsdec(const unsigned char* start, const unsigned char* cur)
......
...@@ -358,7 +358,7 @@ ...@@ -358,7 +358,7 @@
@ cdecl _mbbtype(long long) @ cdecl _mbbtype(long long)
# extern _mbcasemap # extern _mbcasemap
@ cdecl _mbccpy (str str) @ cdecl _mbccpy (str str)
@ stub _mbcjistojms #(long) @ cdecl _mbcjistojms (long)
@ stub _mbcjmstojis #(long) @ stub _mbcjmstojis #(long)
@ cdecl _mbclen(ptr) @ cdecl _mbclen(ptr)
@ stub _mbctohira #(long) @ stub _mbctohira #(long)
......
...@@ -597,6 +597,28 @@ static void test_wcscpy_s(void) ...@@ -597,6 +597,28 @@ static void test_wcscpy_s(void)
ok(szDestShort[0] == 0, "szDestShort[0] not 0\n"); 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) START_TEST(string)
{ {
char mem[100]; char mem[100];
...@@ -637,6 +659,7 @@ START_TEST(string) ...@@ -637,6 +659,7 @@ START_TEST(string)
test_strcpy_s(); test_strcpy_s();
test_strcat_s(); test_strcat_s();
test__mbsnbcpy_s(); test__mbsnbcpy_s();
test_mbcjisjms();
test_wcscpy_s(); test_wcscpy_s();
} }
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