msvcrt: Implement _mbcjmstojis.

This commit is contained in:
Akihiro Sagawa 2012-03-15 23:41:33 +09:00 committed by Alexandre Julliard
parent 0800572257
commit c9f1489cab
3 changed files with 20 additions and 7 deletions

View File

@ -474,7 +474,23 @@ unsigned int CDECL _mbcjmstojis(unsigned int c)
In all other cases, c is returned unchanged */
if(get_mbcinfo()->mbcodepage == 932)
{
FIXME("(%x): stub\n", c);
if(_ismbclegal(c) && HIBYTE(c) < 0xf0)
{
if(HIBYTE(c) >= 0xe0)
c -= 0x4000;
c = (((HIBYTE(c) - 0x81)*2 + 0x21) << 8) | LOBYTE(c);
if(LOBYTE(c) > 0x7f)
c -= 0x1;
if(LOBYTE(c) > 0x9d)
c += 0x83;
else
c -= 0x1f;
}
else
return 0; /* Codepage is 932, but c can't be converted */
}
return c;

View File

@ -913,6 +913,7 @@ int _setmbcp_l(int, LCID, MSVCRT_pthreadmbcinfo) DECLSPEC_HIDDEN;
int __cdecl MSVCRT__write(int,const void*,unsigned int);
int __cdecl _getch(void);
int __cdecl _ismbblead(unsigned int);
int __cdecl _ismbclegal(unsigned int c);
int __cdecl _ismbstrail(const unsigned char* start, const unsigned char* str);
MSVCRT_size_t __cdecl MSVCRT_mbstowcs(MSVCRT_wchar_t*,const char*,MSVCRT_size_t);
MSVCRT_intptr_t __cdecl MSVCRT__spawnve(int,const char*,const char* const *,const char* const *);

View File

@ -901,10 +901,6 @@ static void test_mbcjmsjis(void)
unsigned int ret, exp;
ret = _mbcjmstojis(jmsjis[j][0]);
exp = (cp[i] == 932) ? jmsjis[j][1] : jmsjis[j][0];
if (cp[i] == 932)
todo_wine ok(ret == exp, "Expected 0x%x, got 0x%x (0x%x, codepage=%d)\n",
exp, ret, jmsjis[j][0], cp[i]);
else
ok(ret == exp, "Expected 0x%x, got 0x%x (0x%x, codepage=%d)\n",
exp, ret, jmsjis[j][0], cp[i]);
}