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
44  : _Mybase(_Refs)
45  { // construct with ref count
46  }
codecvt< _Elem, char, _Statype > _Mybase
Definition: codecvt:36
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
49  { // destroy the object
50  }

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 >.

215  { // return true if conversions never change input
216  return (false);
217  }
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.

226  { // return length of code sequence (from codecvt)
227  return ((_Mymode & (consume_header | generate_header)) != 0
228  ? -1 : 0); // -1 => state dependent, 0 => varying length
229  }
Definition: codecvt:23
Definition: codecvt:22
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 >.

56  { // convert bytes [_First1, _Last1) to [_First2, _Last)
57  char *_Pstate = (char *)&_State;
58  _Mid1 = _First1;
59  _Mid2 = _First2;
60 
61  for (; _Mid1 != _Last1 && _Mid2 != _Last2; )
62  { // convert a multibyte sequence
63  unsigned char _By = (unsigned char)*_Mid1;
64  unsigned long _Ch;
65  int _Nextra;
66 
67  if (_By < 0x80)
68  _Ch = _By, _Nextra = 0;
69  else if (_By < 0xc0)
70  { // 0x80-0xdf not first byte
71  ++_Mid1;
72  return (_Mybase::error);
73  }
74  else if (_By < 0xe0)
75  _Ch = _By & 0x1f, _Nextra = 1;
76  else if (_By < 0xf0)
77  _Ch = _By & 0x0f, _Nextra = 2;
78  else if (_By < 0xf8)
79  _Ch = _By & 0x07, _Nextra = 3;
80  else
81  _Ch = _By & 0x03, _Nextra = _By < 0xfc ? 4 : 5;
82 
83  if (_Nextra == 0)
84  ++_Mid1;
85  else if (_Last1 - _Mid1 < _Nextra + 1)
86  break; // not enough input
87  else
88  for (++_Mid1; 0 < _Nextra; --_Nextra, ++_Mid1)
89  if ((_By = (unsigned char)*_Mid1) < 0x80 || 0xc0 <= _By)
90  return (_Mybase::error); // not continuation byte
91  else
92  _Ch = _Ch << 6 | (_By & 0x3f);
93 
94  if (*_Pstate == 0)
95  { // first time, maybe look for and consume header
96  *_Pstate = 1;
97 
98  if ((_Mymode & consume_header) != 0 && _Ch == 0xfeff)
99  { // drop header and retry
100  result _Ans = do_in(_State, _Mid1, _Last1, _Mid1,
101  _First2, _Last2, _Mid2);
102 
103  if (_Ans == _Mybase::partial)
104  { // roll back header determination
105  *_Pstate = 0;
106  _Mid1 = _First1;
107  }
108  return (_Ans);
109  }
110  }
111 
112  if (_Mymax < _Ch)
113  return (_Mybase::error); // code too large
114  *_Mid2++ = (_Elem)_Ch;
115  }
116 
117  return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
118  }
Definition: xlocale:822
Definition: xlocale:822
Definition: codecvt:22
_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:53
Definition: xlocale:822
_Mybase::result result
Definition: codecvt:37
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 >.

184  { // return min(_Count, converted length of bytes [_First1, _Last1))
185  size_t _Wchars = 0;
186  _Statype _Mystate = _State;
187 
188  for (; _Wchars < _Count && _First1 != _Last1; )
189  { // convert another wide character
190  const _Byte *_Mid1;
191  _Elem *_Mid2;
192  _Elem _Ch;
193 
194  switch (do_in(_Mystate, _First1, _Last1, _Mid1,
195  &_Ch, &_Ch + 1, _Mid2))
196  { // test result of single wide-char conversion
197  case _Mybase::noconv:
198  return ((int)(_Wchars + (_Last1 - _First1)));
199 
200  case _Mybase::ok:
201  if (_Mid2 == &_Ch + 1)
202  ++_Wchars; // replacement do_in might not convert one
203  _First1 = _Mid1;
204  break;
205 
206  default:
207  return ((int)_Wchars); // error or partial
208  }
209  }
210 
211  return ((int)_Wchars);
212  }
char _Byte
Definition: codecvt:38
unsigned int _Count
Definition: xcomplex:668
Definition: xlocale:822
Definition: xlocale:822
_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:53
_CSTD mbstate_t _Statype
Definition: codecvt:26
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.

220  { // return maximum length required for a conversion
221  return ((_Mymode & (consume_header | generate_header)) != 0
222  ? 9 : 6);
223  }
Definition: codecvt:23
Definition: codecvt:22
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 >.

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

177  { // generate bytes to return to default shift state
178  _Mid2 = _First2;
179  return (_Mybase::ok);
180  }
Definition: xlocale:822

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