diff --git a/reactos/dll/win32/msvcrt/msvcrt.spec b/reactos/dll/win32/msvcrt/msvcrt.spec index 4c3131bac9b..9e23b5ce679 100644 --- a/reactos/dll/win32/msvcrt/msvcrt.spec +++ b/reactos/dll/win32/msvcrt/msvcrt.spec @@ -156,7 +156,7 @@ @ cdecl __isascii(long) @ cdecl __iscsym(long) @ cdecl __iscsymf(long) -@ extern __lc_codepage MSVCRT___lc_codepage +@ extern __lc_codepage # @ stub __lc_collate # not in XP / 7 @ extern __lc_collate_cp MSVCRT___lc_collate_cp @ extern __lc_handle MSVCRT___lc_handle diff --git a/reactos/lib/sdk/crt/include/internal/mbstring.h b/reactos/lib/sdk/crt/include/internal/mbstring.h index 8ceb83fa921..bf81b5d640f 100644 --- a/reactos/lib/sdk/crt/include/internal/mbstring.h +++ b/reactos/lib/sdk/crt/include/internal/mbstring.h @@ -39,7 +39,6 @@ #define MAX_LOCALE_LENGTH 256 extern unsigned char _mbctype[257]; -extern unsigned int MSVCRT___lc_codepage; extern char MSVCRT_current_lc_all[MAX_LOCALE_LENGTH]; #if defined (_MSC_VER) diff --git a/reactos/lib/sdk/crt/include/internal/wine/msvcrt.h b/reactos/lib/sdk/crt/include/internal/wine/msvcrt.h index 4c15a17e8a9..c771f83d134 100644 --- a/reactos/lib/sdk/crt/include/internal/wine/msvcrt.h +++ b/reactos/lib/sdk/crt/include/internal/wine/msvcrt.h @@ -25,7 +25,7 @@ #include "windef.h" #include "winbase.h" -extern int __lc_codepage; +extern unsigned int __lc_codepage; extern int __lc_collate_cp; extern int __mb_cur_max; extern const unsigned short _ctype [257]; diff --git a/reactos/lib/sdk/crt/locale/locale.c b/reactos/lib/sdk/crt/locale/locale.c index 1c7f76fb889..557b99c24e0 100644 --- a/reactos/lib/sdk/crt/locale/locale.c +++ b/reactos/lib/sdk/crt/locale/locale.c @@ -31,7 +31,7 @@ #error _pctype should not be defined #endif -unsigned int MSVCRT___lc_codepage = 0; +unsigned int __lc_codepage = 0; int MSVCRT___lc_collate_cp = 0; LCID MSVCRT___lc_handle[LC_MAX - LC_MIN + 1] = { 0 }; int __mb_cur_max = 1; @@ -622,7 +622,7 @@ LCID* CDECL ___lc_handle_func(void) */ unsigned int CDECL ___lc_codepage_func(void) { - return MSVCRT___lc_codepage; + return __lc_codepage; } /********************************************************************* @@ -1391,7 +1391,7 @@ char* CDECL setlocale(int category, const char* locale) if(locinfo == MSVCRT_locale->locinfo) { int i; - MSVCRT___lc_codepage = locinfo->lc_codepage; + __lc_codepage = locinfo->lc_codepage; MSVCRT___lc_collate_cp = locinfo->lc_collate_cp; __mb_cur_max = locinfo->mb_cur_max; _pctype = locinfo->pctype; @@ -1488,7 +1488,7 @@ void __init_global_locale() return; global_locale = MSVCRT__create_locale(0, "C"); - MSVCRT___lc_codepage = MSVCRT_locale->locinfo->lc_codepage; + __lc_codepage = MSVCRT_locale->locinfo->lc_codepage; MSVCRT___lc_collate_cp = MSVCRT_locale->locinfo->lc_collate_cp; __mb_cur_max = MSVCRT_locale->locinfo->mb_cur_max; for(i=LC_MIN; i<=LC_MAX; i++) diff --git a/reactos/lib/sdk/crt/mbstring/jistojms.c b/reactos/lib/sdk/crt/mbstring/jistojms.c index 76a2424467f..d4835855bdf 100644 --- a/reactos/lib/sdk/crt/mbstring/jistojms.c +++ b/reactos/lib/sdk/crt/mbstring/jistojms.c @@ -33,7 +33,7 @@ unsigned int _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(get_mbcinfo()->mbcodepage == 932) { if(HIBYTE(c) >= 0x21 && HIBYTE(c) <= 0x7e && LOBYTE(c) >= 0x21 && LOBYTE(c) <= 0x7e) @@ -43,7 +43,7 @@ unsigned int _mbcjistojms(unsigned int c) else c += 0x7d; - if(LOBYTE(c) > 0x7F) + if(LOBYTE(c) >= 0x7F) c += 0x1; c = (((HIBYTE(c) - 0x21)/2 + 0x81) << 8) | LOBYTE(c); diff --git a/reactos/lib/sdk/crt/mbstring/jmstojis.c b/reactos/lib/sdk/crt/mbstring/jmstojis.c index 8e634c3e67d..97225453749 100644 --- a/reactos/lib/sdk/crt/mbstring/jmstojis.c +++ b/reactos/lib/sdk/crt/mbstring/jmstojis.c @@ -1,28 +1,34 @@ +#include #include +#include /* * @implemented */ -unsigned int _mbcjmstojis(unsigned int c) +unsigned int __cdecl _mbcjmstojis(unsigned int c) { - int c1, c2; + /* Conversion takes place only when codepage is 932. + In all other cases, c is returned unchanged */ + if(get_mbcinfo()->mbcodepage == 932) + { + if(_ismbclegal(c) && HIBYTE(c) < 0xf0) + { + if(HIBYTE(c) >= 0xe0) + c -= 0x4000; - c2 = (unsigned char)c; - c1 = c >> 8; - if (c1 < 0xf0 && _ismbblead(c1) && _ismbbtrail(c2)) { - if (c1 >= 0xe0) - c1 -= 0x40; - c1 -= 0x70; - c1 <<= 1; - if (c2 < 0x9f) { - c1 --; - c2 -= 0x1f; - if (c2 >= (0x80-0x1f)) - c2 --; - } else { - c2 -= 0x7e; + c = (((HIBYTE(c) - 0x81)*2 + 0x21) << 8) | LOBYTE(c); + + if(LOBYTE(c) > 0x7f) + c -= 0x1; + + if(LOBYTE(c) > 0x9d) + c += 0x83; + else + c -= 0x1f; } - return ((c1 << 8) | c2); + else + return 0; /* Codepage is 932, but c can't be converted */ } - return 0; + + return c; }