12 #if defined( _SMALL_PRINTF ) || defined(SMALL_SCANF)
18 #define __state __count
21 extern char __lc_ctype[12];
24 _DEFUN (_wctomb_r, (r, s, wchar, state),
33 if (strlen (__lc_ctype) <= 1)
35 else if (!strcmp (__lc_ctype,
"C-UTF-8"))
45 else if (wchar >= 0x80 && wchar <= 0x7ff)
47 *s++ = 0xc0 | ((wchar & 0x7c0) >> 6);
48 *s = 0x80 | (wchar & 0x3f);
51 else if (wchar >= 0x800 && wchar <= 0xffff)
54 if (wchar >= 0xd800 && wchar <= 0xdfff)
57 *s++ = 0xe0 | ((wchar & 0xf000) >> 12);
58 *s++ = 0x80 | ((wchar & 0xfc0) >> 6);
59 *s = 0x80 | (wchar & 0x3f);
62 else if (wchar >= 0x10000 && wchar <= 0x1fffff)
64 *s++ = 0xf0 | ((wchar & 0x1c0000) >> 18);
65 *s++ = 0x80 | ((wchar & 0x3f000) >> 12);
66 *s++ = 0x80 | ((wchar & 0xfc0) >> 6);
67 *s = 0x80 | (wchar & 0x3f);
70 else if (wchar >= 0x200000 && wchar <= 0x3ffffff)
72 *s++ = 0xf8 | ((wchar & 0x3000000) >> 24);
73 *s++ = 0x80 | ((wchar & 0xfc0000) >> 18);
74 *s++ = 0x80 | ((wchar & 0x3f000) >> 12);
75 *s++ = 0x80 | ((wchar & 0xfc0) >> 6);
76 *s = 0x80 | (wchar & 0x3f);
79 else if (wchar >= 0x4000000 && wchar <= 0x7fffffff)
81 *s++ = 0xfc | ((wchar & 0x40000000) >> 30);
82 *s++ = 0x80 | ((wchar & 0x3f000000) >> 24);
83 *s++ = 0x80 | ((wchar & 0xfc0000) >> 18);
84 *s++ = 0x80 | ((wchar & 0x3f000) >> 12);
85 *s++ = 0x80 | ((wchar & 0xfc0) >> 6);
86 *s = 0x80 | (wchar & 0x3f);
92 else if (!strcmp (__lc_ctype,
"C-SJIS"))
94 unsigned char char2 = (
unsigned char)wchar;
95 unsigned char char1 = (
unsigned char)(wchar >> 8);
103 if (_issjis1(char1) && _issjis2(char2))
113 else if (!strcmp (__lc_ctype,
"C-EUCJP"))
115 unsigned char char2 = (
unsigned char)wchar;
116 unsigned char char1 = (
unsigned char)(wchar >> 8);
124 if (_iseucjp (char1) && _iseucjp (char2))
134 else if (!strcmp (__lc_ctype,
"C-JIS"))
137 unsigned char char2 = (
unsigned char)wchar;
138 unsigned char char1 = (
unsigned char)(wchar >> 8);
146 if (_isjis (char1) && _isjis (char2))
148 if (state->__state == 0)
166 if (state->__state != 0)