STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Protected Member Functions | List of all members
codecvt_utf8< _Elem, _Mymax, _Mymode > Class Template Reference
Inheritance diagram for codecvt_utf8< _Elem, _Mymax, _Mymode >:
codecvt< _Elem, char, _Statype > codecvt_base locale::facet _Facet_base _Crt_new_delete

Public Types

typedef codecvt< _Elem, char, _Statype_Mybase
 
typedef _Mybase::result result
 
typedef char _Byte
 
typedef _Elem intern_type
 
typedef _Byte extern_type
 
typedef _Statype state_type
 
- Public Types inherited from codecvt< _Elem, char, _Statype >
typedef _Elem intern_type
 
typedef char extern_type
 
typedef _Statype state_type
 
- Public Types inherited from codecvt_base
enum  { ok, partial, error, noconv }
 
typedef int result
 

Public Member Functions

 codecvt_utf8 (size_t _Refs=0)
 
virtual __CLR_OR_THIS_CALL ~codecvt_utf8 () _NOEXCEPT
 
- Public Member Functions inherited from codecvt< _Elem, char, _Statype >
result __CLR_OR_THIS_CALL in (_Statype &_State, const char *_First1, const char *_Last1, const char *&_Mid1, _Elem *_First2, _Elem *_Last2, _Elem *&_Mid2) const
 
result __CLR_OR_THIS_CALL out (_Statype &_State, const _Elem *_First1, const _Elem *_Last1, const _Elem *&_Mid1, char *_First2, char *_Last2, char *&_Mid2) const
 
result __CLR_OR_THIS_CALL unshift (_Statype &_State, char *_First2, char *_Last2, char *&_Mid2) const
 
int __CLR_OR_THIS_CALL length (_Statype &_State, const char *_First1, const char *_Last1, size_t _Count) const
 
__CLR_OR_THIS_CALL codecvt (size_t _Refs=0)
 
__CLR_OR_THIS_CALL codecvt (const _Locinfo &_Lobj, size_t _Refs=0)
 
- Public Member Functions inherited from codecvt_base
__CLR_OR_THIS_CALL codecvt_base (size_t _Refs=0)
 
bool __CLR_OR_THIS_CALL always_noconv () const _THROW0()
 
int __CLR_OR_THIS_CALL max_length () const _THROW0()
 
int __CLR_OR_THIS_CALL encoding () const _THROW0()
 
__CLR_OR_THIS_CALL ~codecvt_base () _NOEXCEPT
 
- Public Member Functions inherited from locale::facet
virtual void __CLR_OR_THIS_CALL _Incref ()
 
virtual _Facet_base *__CLR_OR_THIS_CALL _Decref ()
 
__CLR_OR_THIS_CALL facet (const facet &)=delete
 
facet &__CLR_OR_THIS_CALL operator= (const facet &)=delete
 
- Public Member Functions inherited from _Facet_base
virtual __CLR_OR_THIS_CALL ~_Facet_base () _NOEXCEPT
 

Protected Member Functions

virtual result __CLR_OR_THIS_CALL do_in (_Statype &_State, const _Byte *_First1, const _Byte *_Last1, const _Byte *&_Mid1, _Elem *_First2, _Elem *_Last2, _Elem *&_Mid2) const
 
virtual result __CLR_OR_THIS_CALL do_out (_Statype &_State, const _Elem *_First1, const _Elem *_Last1, const _Elem *&_Mid1, _Byte *_First2, _Byte *_Last2, _Byte *&_Mid2) const
 
virtual result __CLR_OR_THIS_CALL do_unshift (_Statype &, _Byte *_First2, _Byte *, _Byte *&_Mid2) const
 
virtual int __CLR_OR_THIS_CALL do_length (_Statype &_State, const _Byte *_First1, const _Byte *_Last1, size_t _Count) const _THROW0()
 
virtual bool __CLR_OR_THIS_CALL do_always_noconv () const _THROW0()
 
virtual int __CLR_OR_THIS_CALL do_max_length () const _THROW0()
 
virtual int __CLR_OR_THIS_CALL do_encoding () const _THROW0()
 
- Protected Member Functions inherited from codecvt< _Elem, char, _Statype >
virtual __CLR_OR_THIS_CALL ~codecvt () _NOEXCEPT
 
void __CLR_OR_THIS_CALL _Init (const _Locinfo &)
 
- Protected Member Functions inherited from locale::facet
__CLR_OR_THIS_CALL facet (size_t _Initrefs=0)
 
virtual __CLR_OR_THIS_CALL ~facet () _NOEXCEPT
 

Additional Inherited Members

- Static Public Member Functions inherited from codecvt< _Elem, char, _Statype >
static size_t __CLRCALL_OR_CDECL _Getcat (const locale::facet **_Ppf=0, const locale *_Ploc=0)
 
- Static Public Member Functions inherited from locale::facet
static size_t __CLRCALL_OR_CDECL _Getcat (const facet **=0, const locale *=0)
 
- Static Public Attributes inherited from codecvt< _Elem, char, _Statype >
static __PURE_APPDOMAIN_GLOBAL locale::id id
 

Member Typedef Documentation

template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
typedef char codecvt_utf8< _Elem, _Mymax, _Mymode >::_Byte
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
typedef codecvt<_Elem, char, _Statype> codecvt_utf8< _Elem, _Mymax, _Mymode >::_Mybase
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
typedef _Byte codecvt_utf8< _Elem, _Mymax, _Mymode >::extern_type
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
typedef _Elem codecvt_utf8< _Elem, _Mymax, _Mymode >::intern_type
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
typedef _Mybase::result codecvt_utf8< _Elem, _Mymax, _Mymode >::result
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
typedef _Statype codecvt_utf8< _Elem, _Mymax, _Mymode >::state_type

Constructor & Destructor Documentation

template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
codecvt_utf8< _Elem, _Mymax, _Mymode >::codecvt_utf8 ( size_t  _Refs = 0)
inlineexplicit
46  : _Mybase(_Refs)
47  { // construct with ref count
48  }
codecvt< _Elem, char, _Statype > _Mybase
Definition: codecvt:38
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
virtual __CLR_OR_THIS_CALL codecvt_utf8< _Elem, _Mymax, _Mymode >::~codecvt_utf8 ( )
inlinevirtual
51  { // destroy the object
52  }

Member Function Documentation

template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
virtual bool __CLR_OR_THIS_CALL codecvt_utf8< _Elem, _Mymax, _Mymode >::do_always_noconv ( ) const
inlineprotectedvirtual

Reimplemented from codecvt< _Elem, char, _Statype >.

217  { // return true if conversions never change input
218  return (false);
219  }
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
virtual int __CLR_OR_THIS_CALL codecvt_utf8< _Elem, _Mymax, _Mymode >::do_encoding ( ) const
inlineprotectedvirtual

Reimplemented from codecvt_base.

228  { // return length of code sequence (from codecvt)
229  return ((_Mymode & (consume_header | generate_header)) != 0
230  ? -1 : 0); // -1 => state dependent, 0 => varying length
231  }
Definition: codecvt:25
Definition: codecvt:24
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
virtual result __CLR_OR_THIS_CALL codecvt_utf8< _Elem, _Mymax, _Mymode >::do_in ( _Statype _State,
const _Byte _First1,
const _Byte _Last1,
const _Byte *&  _Mid1,
_Elem *  _First2,
_Elem *  _Last2,
_Elem *&  _Mid2 
) const
inlineprotectedvirtual

Reimplemented from codecvt< _Elem, char, _Statype >.

58  { // convert bytes [_First1, _Last1) to [_First2, _Last)
59  char *_Pstate = (char *)&_State;
60  _Mid1 = _First1;
61  _Mid2 = _First2;
62 
63  for (; _Mid1 != _Last1 && _Mid2 != _Last2; )
64  { // convert a multibyte sequence
65  unsigned char _By = (unsigned char)*_Mid1;
66  unsigned long _Ch;
67  int _Nextra;
68 
69  if (_By < 0x80)
70  _Ch = _By, _Nextra = 0;
71  else if (_By < 0xc0)
72  { // 0x80-0xdf not first byte
73  ++_Mid1;
74  return (_Mybase::error);
75  }
76  else if (_By < 0xe0)
77  _Ch = _By & 0x1f, _Nextra = 1;
78  else if (_By < 0xf0)
79  _Ch = _By & 0x0f, _Nextra = 2;
80  else if (_By < 0xf8)
81  _Ch = _By & 0x07, _Nextra = 3;
82  else
83  _Ch = _By & 0x03, _Nextra = _By < 0xfc ? 4 : 5;
84 
85  if (_Nextra == 0)
86  ++_Mid1;
87  else if (_Last1 - _Mid1 < _Nextra + 1)
88  break; // not enough input
89  else
90  for (++_Mid1; 0 < _Nextra; --_Nextra, ++_Mid1)
91  if ((_By = (unsigned char)*_Mid1) < 0x80 || 0xc0 <= _By)
92  return (_Mybase::error); // not continuation byte
93  else
94  _Ch = _Ch << 6 | (_By & 0x3f);
95 
96  if (*_Pstate == 0)
97  { // first time, maybe look for and consume header
98  *_Pstate = 1;
99 
100  if ((_Mymode & consume_header) != 0 && _Ch == 0xfeff)
101  { // drop header and retry
102  result _Ans = do_in(_State, _Mid1, _Last1, _Mid1,
103  _First2, _Last2, _Mid2);
104 
105  if (_Ans == _Mybase::partial)
106  { // roll back header determination
107  *_Pstate = 0;
108  _Mid1 = _First1;
109  }
110  return (_Ans);
111  }
112  }
113 
114  if (_Mymax < _Ch)
115  return (_Mybase::error); // code too large
116  *_Mid2++ = (_Elem)_Ch;
117  }
118 
119  return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
120  }
Definition: xlocale:759
Definition: codecvt:24
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
virtual result __CLR_OR_THIS_CALL do_in(_Statype &_State, const _Byte *_First1, const _Byte *_Last1, const _Byte *&_Mid1, _Elem *_First2, _Elem *_Last2, _Elem *&_Mid2) const
Definition: codecvt:55
_In_ size_t _Deref_pre_opt_z_ char const _In_ size_t _Inout_ mbstate_t * _State
Definition: wchar.h:78
unsigned char
Definition: mbstring.h:107
Definition: xlocale:759
_Mybase::result result
Definition: codecvt:39
Definition: xlocale:759
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
virtual int __CLR_OR_THIS_CALL codecvt_utf8< _Elem, _Mymax, _Mymode >::do_length ( _Statype _State,
const _Byte _First1,
const _Byte _Last1,
size_t  _Count 
) const
inlineprotectedvirtual

Reimplemented from codecvt< _Elem, char, _Statype >.

186  { // return min(_Count, converted length of bytes [_First1, _Last1))
187  size_t _Wchars = 0;
188  _Statype _Mystate = _State;
189 
190  for (; _Wchars < _Count && _First1 != _Last1; )
191  { // convert another wide character
192  const _Byte *_Mid1;
193  _Elem *_Mid2;
194  _Elem _Ch;
195 
196  switch (do_in(_Mystate, _First1, _Last1, _Mid1,
197  &_Ch, &_Ch + 1, _Mid2))
198  { // test result of single wide-char conversion
199  case _Mybase::noconv:
200  return ((int)(_Wchars + (_Last1 - _First1)));
201 
202  case _Mybase::ok:
203  if (_Mid2 == &_Ch + 1)
204  ++_Wchars; // replacement do_in might not convert one
205  _First1 = _Mid1;
206  break;
207 
208  default:
209  return ((int)_Wchars); // error or partial
210  }
211  }
212 
213  return ((int)_Wchars);
214  }
char _Byte
Definition: codecvt:40
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
virtual result __CLR_OR_THIS_CALL do_in(_Statype &_State, const _Byte *_First1, const _Byte *_Last1, const _Byte *&_Mid1, _Elem *_First2, _Elem *_Last2, _Elem *&_Mid2) const
Definition: codecvt:55
_In_ size_t _Deref_pre_opt_z_ char const _In_ size_t _Inout_ mbstate_t * _State
Definition: wchar.h:78
_Diff _Count
Definition: algorithm:1941
Definition: xlocale:759
Definition: xlocale:759
_CSTD mbstate_t _Statype
Definition: codecvt:28
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
virtual int __CLR_OR_THIS_CALL codecvt_utf8< _Elem, _Mymax, _Mymode >::do_max_length ( ) const
inlineprotectedvirtual

Reimplemented from codecvt_base.

222  { // return maximum length required for a conversion
223  return ((_Mymode & (consume_header | generate_header)) != 0
224  ? 9 : 6);
225  }
Definition: codecvt:25
Definition: codecvt:24
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
virtual result __CLR_OR_THIS_CALL codecvt_utf8< _Elem, _Mymax, _Mymode >::do_out ( _Statype _State,
const _Elem *  _First1,
const _Elem *  _Last1,
const _Elem *&  _Mid1,
_Byte _First2,
_Byte _Last2,
_Byte *&  _Mid2 
) const
inlineprotectedvirtual

Reimplemented from codecvt< _Elem, char, _Statype >.

125  { // convert [_First1, _Last1) to bytes [_First2, _Last)
126  char *_Pstate = (char *)&_State;
127  _Mid1 = _First1;
128  _Mid2 = _First2;
129 
130  for (; _Mid1 != _Last1 && _Mid2 != _Last2; )
131  { // convert and put a wide char
132  _Byte _By;
133  int _Nextra;
134  unsigned long _Ch = (unsigned long)*_Mid1;
135 
136  if (_Mymax < _Ch)
137  return (_Mybase::error);
138 
139  if (_Ch < 0x0080)
140  _By = (_Byte)_Ch, _Nextra = 0;
141  else if (_Ch < 0x0800)
142  _By = (_Byte)(0xc0 | _Ch >> 6), _Nextra = 1;
143  else if (_Ch < 0x00010000)
144  _By = (_Byte)(0xe0 | _Ch >> 12), _Nextra = 2;
145  else if (_Ch < 0x00200000)
146  _By = (_Byte)(0xf0 | _Ch >> 18), _Nextra = 3;
147  else if (_Ch < 0x04000000)
148  _By = (_Byte)(0xf8 | _Ch >> 24), _Nextra = 4;
149  else
150  _By = (_Byte)(0xfc | (_Ch >> 30 & 0x03)), _Nextra = 5;
151 
152  if (*_Pstate == 0)
153  { // first time, maybe generate header
154  *_Pstate = 1;
155  if ((_Mymode & generate_header) == 0)
156  ;
157  else if (_Last2 - _Mid2 < 3 + 1 + _Nextra)
158  return (_Mybase::partial); // not enough room for both
159  else
160  { // prepend header
161  *_Mid2++ = (_Byte)(unsigned char)0xef;
162  *_Mid2++ = (_Byte)(unsigned char)0xbb;
163  *_Mid2++ = (_Byte)(unsigned char)0xbf;
164  }
165  }
166 
167  if (_Last2 - _Mid2 < 1 + _Nextra)
168  break; // not enough room for output
169 
170  ++_Mid1;
171  for (*_Mid2++ = _By; 0 < _Nextra; )
172  *_Mid2++ = (_Byte)((_Ch >> 6 * --_Nextra & 0x3f) | 0x80);
173  }
174  return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
175  }
char _Byte
Definition: codecvt:40
Definition: codecvt:25
_In_ long
Definition: corecrt_wstdlib.h:88
Definition: xlocale:759
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
_In_ size_t _Deref_pre_opt_z_ char const _In_ size_t _Inout_ mbstate_t * _State
Definition: wchar.h:78
Definition: xlocale:759
Definition: xlocale:759
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
virtual result __CLR_OR_THIS_CALL codecvt_utf8< _Elem, _Mymax, _Mymode >::do_unshift ( _Statype ,
_Byte _First2,
_Byte ,
_Byte *&  _Mid2 
) const
inlineprotectedvirtual

Reimplemented from codecvt< _Elem, char, _Statype >.

179  { // generate bytes to return to default shift state
180  _Mid2 = _First2;
181  return (_Mybase::ok);
182  }
Definition: xlocale:759

The documentation for this class was generated from the following file: