58 unsigned short *_Pstate = (
unsigned short *)&_State;
62 for (; _Mid1 != _Last1 && _Mid2 != _Last2; )
64 unsigned char _By = (
unsigned char)*_Mid1;
70 else if (_By < 0x80 || 0xc0 <= _By)
71 return (_Mybase::error);
75 *_Mid2++ = (_Elem)(*_Pstate | (_By & 0x3f));
81 _Ch = _By, _Nextra = 0;
85 return (_Mybase::error);
88 _Ch = _By & 0x1f, _Nextra = 1;
90 _Ch = _By & 0x0f, _Nextra = 2;
92 _Ch = _By & 0x07, _Nextra = 3;
94 _Ch = _By & 0x03, _Nextra = _By < 0xfc ? 4 : 5;
96 _Nskip = _Nextra < 3 ? 0 : 1;
101 else if (_Last1 - _Mid1 < _Nextra + 1 - _Nskip)
104 for (++_Mid1; _Nskip < _Nextra; --_Nextra, ++_Mid1)
105 if ((_By = (
unsigned char)*_Mid1) < 0x80 || 0xc0 <= _By)
106 return (_Mybase::error);
108 _Ch = _Ch << 6 | (_By & 0x3f);
112 if ((_Maxcode < 0x10ffff ? _Maxcode : 0x10ffff) <
_Ch)
113 return (_Mybase::error);
114 else if (0xffff < _Ch)
116 unsigned short _Ch0 =
117 (
unsigned short)(0xd800 | (_Ch >> 10) - 0x0040);
119 *_Mid2++ = (_Elem)_Ch0;
120 *_Pstate = (
unsigned short)(0xdc00 | (_Ch & 0x03ff));
126 else if (_Mid1 == _Last1)
131 else if ((_By = (
unsigned char)*_Mid1++) < 0x80 || 0xc0 <= _By)
132 return (_Mybase::error);
143 _First2, _Last2, _Mid2);
145 if (_Ans == _Mybase::partial)
154 *_Mid2++ = (_Elem)_Ch;
157 return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
_Check_return_ _In_ int _Mode
Definition: io.h:338
_Mybase::result result
Definition: utf8_utf16:34
_In_ size_t _In_ unsigned int _Ch
Definition: mbstring.h:161
virtual result do_in(_Statype &_State, const _Byte *_First1, const _Byte *_Last1, const _Byte *&_Mid1, _Elem *_First2, _Elem *_Last2, _Elem *&_Mid2) const
Definition: utf8_utf16:54