59 unsigned short *_Pstate = (
unsigned short *)&
_State;
63 for (; _Mid1 != _Last1 && _Mid2 != _Last2; )
65 unsigned char _By = (
unsigned char)*_Mid1;
71 else if (_By < 0x80 || 0xc0 <= _By)
72 return (_Mybase::error);
76 *_Mid2++ = (_Elem)(*_Pstate | (_By & 0x3f));
82 _Ch = _By, _Nextra = 0;
86 return (_Mybase::error);
89 _Ch = _By & 0x1f, _Nextra = 1;
91 _Ch = _By & 0x0f, _Nextra = 2;
93 _Ch = _By & 0x07, _Nextra = 3;
95 _Ch = _By & 0x03, _Nextra = _By < 0xfc ? 4 : 5;
97 _Nskip = _Nextra < 3 ? 0 : 1;
102 else if (_Last1 - _Mid1 < _Nextra + 1 - _Nskip)
105 for (++_Mid1; _Nskip < _Nextra; --_Nextra, ++_Mid1)
106 if ((_By = (
unsigned char)*_Mid1) < 0x80 || 0xc0 <= _By)
107 return (_Mybase::error);
109 _Ch = _Ch << 6 | (_By & 0x3f);
113 if ((_Maxcode < 0x10ffff ? _Maxcode : 0x10ffff) <
_Ch)
114 return (_Mybase::error);
115 else if (0xffff < _Ch)
117 unsigned short _Ch0 =
118 (
unsigned short)(0xd800 | (_Ch >> 10) - 0x0040);
120 *_Mid2++ = (_Elem)_Ch0;
121 *_Pstate = (
unsigned short)(0xdc00 | (_Ch & 0x03ff));
127 else if (_Mid1 == _Last1)
132 else if ((_By = (
unsigned char)*_Mid1++) < 0x80 || 0xc0 <= _By)
133 return (_Mybase::error);
144 _First2, _Last2, _Mid2);
146 if (_Ans == _Mybase::partial)
155 *_Mid2++ = (_Elem)_Ch;
158 return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
_Mybase::result result
Definition: utf8_utf16:35
_In_ size_t _Deref_pre_opt_z_ char const _In_ size_t _Inout_ mbstate_t * _State
Definition: wchar.h:78
_Check_return_ _In_z_ wchar_t const * _Mode
Definition: corecrt_wstdio.h:133
unsigned char
Definition: mbstring.h:107
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:55