ReactOS 0.4.16-dev-927-g467dec4
tojisjms.cpp File Reference
#include <corecrt_internal_mbstring.h>
#include <locale.h>
Include dependency graph for tojisjms.cpp:

Go to the source code of this file.

Functions

unsigned int __cdecl _mbcjistojms_l (unsigned int c, _locale_t plocinfo)
 
unsigned int (__cdecl _mbcjistojms)(unsigned int c)
 
unsigned int __cdecl _mbcjmstojis_l (unsigned int c, _locale_t plocinfo)
 

Function Documentation

◆ _mbcjistojms_l()

unsigned int __cdecl _mbcjistojms_l ( unsigned int  c,
_locale_t  plocinfo 
)

Definition at line 36 of file tojisjms.cpp.

40{
41 unsigned int h, l;
42 _LocaleUpdate _loc_update(plocinfo);
43
44 if (_loc_update.GetLocaleT()->mbcinfo->mbcodepage != _KANJI_CP)
45 return (c);
46
47 h = (c >> 8) & 0xff;
48 l = c & 0xff;
49 if (h < 0x21 || h > 0x7e || l < 0x21 || l > 0x7e)
50 {
51 errno = EILSEQ;
52 return 0;
53 }
54 if (h & 0x01) { /* first byte is odd */
55 if (l <= 0x5f)
56 l += 0x1f;
57 else
58 l += 0x20;
59 }
60 else
61 l += 0x7e;
62
63 h = ((h - 0x21) >> 1) + 0x81;
64 if (h > 0x9f)
65 h += 0x40;
66 return (h << 8) | l;
67}
r l[0]
Definition: byte_order.h:168
#define _KANJI_CP
Definition: mbctype.h:53
const GLubyte * c
Definition: glext.h:8905
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
_locale_t plocinfo
Definition: ismbbyte.cpp:75
#define errno
Definition: errno.h:18
#define EILSEQ
Definition: errno.h:109

Referenced by int().

◆ _mbcjmstojis_l()

unsigned int __cdecl _mbcjmstojis_l ( unsigned int  c,
_locale_t  plocinfo 
)

Definition at line 94 of file tojisjms.cpp.

98{
99 unsigned int h, l;
100 _LocaleUpdate _loc_update(plocinfo);
101
102 if ( _loc_update.GetLocaleT()->mbcinfo->mbcodepage != _KANJI_CP )
103 return (c);
104
105 h = (c >> 8) & 0xff;
106 l = c & 0xff;
107
108 /* make sure input is valid shift-JIS */
109 if ( (!(_ismbblead_l(h, _loc_update.GetLocaleT()))) || (!(_ismbbtrail_l(l, _loc_update.GetLocaleT()))) )
110 {
111 errno = EILSEQ;
112 return 0;
113 }
114
115 h -= (h >= 0xa0) ? 0xc1 : 0x81;
116 if(l >= 0x9f) {
117 c = (h << 9) + 0x2200;
118 c |= l - 0x7e;
119 } else {
120 c = (h << 9) + 0x2100;
121 c |= l - ((l <= 0x7e) ? 0x1f : 0x20);
122 }
123
124 /* not all shift-JIS maps to JIS, so make sure output is valid */
125 if ( (c>0x7E7E) || (c<0x2121) || ((c&0xFF)>0x7E) || ((c&0xFF)<0x21) )
126 {
127 errno = EILSEQ;
128 return 0;
129 }
130
131 return c;
132}
#define _ismbblead_l(_c, p)
#define _ismbbtrail_l(_c, p)
#define c
Definition: ke_i.h:80

◆ int()

unsigned int ( __cdecl  _mbcjistojms)

Definition at line 68 of file tojisjms.cpp.

71{
72 return _mbcjistojms_l(c, nullptr);
73}
unsigned int __cdecl _mbcjistojms_l(unsigned int c, _locale_t plocinfo)
Definition: tojisjms.cpp:36