STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Protected Member Functions | Private Types | List of all members
codecvt_utf16< _Elem, _Mymax, _Mymode > Class Template Reference
Inheritance diagram for codecvt_utf16< _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_utf16 (size_t _Refs=0)
 
virtual __CLR_OR_THIS_CALL ~codecvt_utf16 () _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
 

Private Types

enum  { _Bytes_per_word = 2 }
 

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_utf16< _Elem, _Mymax, _Mymode >::_Byte
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
typedef codecvt<_Elem, char, _Statype> codecvt_utf16< _Elem, _Mymax, _Mymode >::_Mybase
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
typedef _Byte codecvt_utf16< _Elem, _Mymax, _Mymode >::extern_type
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
typedef _Elem codecvt_utf16< _Elem, _Mymax, _Mymode >::intern_type
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
typedef _Mybase::result codecvt_utf16< _Elem, _Mymax, _Mymode >::result
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
typedef _Statype codecvt_utf16< _Elem, _Mymax, _Mymode >::state_type

Member Enumeration Documentation

template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
anonymous enum
private
Enumerator
_Bytes_per_word 
241 {_Bytes_per_word = 2};
Definition: codecvt:241

Constructor & Destructor Documentation

template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
codecvt_utf16< _Elem, _Mymax, _Mymode >::codecvt_utf16 ( size_t  _Refs = 0)
inlineexplicit
251  : _Mybase(_Refs)
252  { // construct with ref count
253  }
codecvt< _Elem, char, _Statype > _Mybase
Definition: codecvt:243
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
virtual __CLR_OR_THIS_CALL codecvt_utf16< _Elem, _Mymax, _Mymode >::~codecvt_utf16 ( )
inlinevirtual
256  { // destroy the object
257  }

Member Function Documentation

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

Reimplemented from codecvt< _Elem, char, _Statype >.

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

Reimplemented from codecvt_base.

478  { // return length of code sequence (from codecvt)
479  return ((_Mymode & (consume_header | generate_header)) != 0
480  ? -1 : 0); // -1 => state dependent, 0 => varying length
481  }
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_utf16< _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 >.

263  { // convert bytes [_First1, _Last1) to [_First2, _Last)
264  char *_Pstate = (char *)&_State;
265  _Mid1 = _First1;
266  _Mid2 = _First2;
267 
268  for (; _Bytes_per_word <= _Last1 - _Mid1 && _Mid2 != _Last2; )
269  { // convert a multibyte sequence
270  unsigned char *_Ptr = (unsigned char *)_Mid1;
271  unsigned long _Ch;
272  unsigned short _Ch0, _Ch1;
273 
274  if (*_Pstate == _LITTLE_FIRST)
275  _Ch0 = (unsigned short)(_Ptr[1] << 8 | _Ptr[0]);
276  else if (*_Pstate == _BIG_FIRST)
277  _Ch0 = (unsigned short)(_Ptr[0] << 8 | _Ptr[1]);
278  else
279  { // no header seen yet, try preferred mode
280  unsigned char _Default_endian = (_Mymode & little_endian) != 0
282 
283  if ((_Mymode & little_endian) != 0)
284  _Ch0 = (unsigned short)(_Ptr[1] << 8 | _Ptr[0]);
285  else
286  _Ch0 = (unsigned short)(_Ptr[0] << 8 | _Ptr[1]);
287  if ((_Mymode & consume_header) == 0
288  || (_Ch0 != 0xfeff && _Ch0 != 0xfffe))
289  *_Pstate = _Default_endian;
290  else
291  { // consume header, fixate on endianness, and retry
292  _Mid1 += _Bytes_per_word;
293  *_Pstate = (char)(_Ch0 == 0xfeff
294  ? _Default_endian
295  : (unsigned char)(3 - _Default_endian));
296  result _Ans = do_in(_State, _Mid1, _Last1, _Mid1,
297  _First2, _Last2, _Mid2);
298 
299  if (_Ans == _Mybase::partial)
300  { // not enough bytes, roll back header
301  *_Pstate = 0;
302  _Mid1 = _First1;
303  }
304  return (_Ans);
305  }
306  }
307 
308  if (_Ch0 < 0xd800 || 0xdc00 <= _Ch0)
309  { // one word, consume bytes
310  _Mid1 += _Bytes_per_word;
311  _Ch = _Ch0;
312  }
313  else if (_Last1 - _Mid1 < 2 * _Bytes_per_word)
314  break;
315  else
316  { // get second word
317  if (*_Pstate == _LITTLE_FIRST)
318  _Ch1 = (unsigned short)(_Ptr[3] << 8 | _Ptr[2]);
319  else
320  _Ch1 = (unsigned short)(_Ptr[2] << 8 | _Ptr[3]);
321 
322  if (_Ch1 < 0xdc00 || 0xe000 <= _Ch1)
323  return (_Mybase::error);
324 
325  _Mid1 += 2 * _Bytes_per_word;
326  _Ch = (unsigned long)(_Ch0 - 0xd800 + 0x0040) << 10
327  | (_Ch1 - 0xdc00);
328  }
329 
330  if (_Mymax < _Ch)
331  return (_Mybase::error); // code too large
332  *_Mid2++ = (_Elem)_Ch;
333  }
334 
335  return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
336  }
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:260
_In_ long
Definition: corecrt_wstdlib.h:88
Definition: codecvt:26
Definition: xlocale:759
Definition: codecvt:24
#define _BIG_FIRST
Definition: codecvt:20
_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
unsigned char
Definition: mbstring.h:107
_Mybase::result result
Definition: codecvt:244
Definition: codecvt:241
#define _LITTLE_FIRST
Definition: codecvt:19
Definition: xlocale:759
Definition: xlocale:759
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
virtual int __CLR_OR_THIS_CALL codecvt_utf16< _Elem, _Mymax, _Mymode >::do_length ( _Statype _State,
const _Byte _First1,
const _Byte _Last1,
size_t  _Count 
) const
inlineprotectedvirtual

Reimplemented from codecvt< _Elem, char, _Statype >.

436  { // return min(_Count, converted length of bytes [_First1, _Last1))
437  size_t _Wchars = 0;
438  _Statype _Mystate = _State;
439 
440  for (; _Wchars < _Count && _First1 != _Last1; )
441  { // convert another wide char
442  const _Byte *_Mid1;
443  _Elem *_Mid2;
444  _Elem _Ch;
445 
446  switch (do_in(_Mystate, _First1, _Last1, _Mid1,
447  &_Ch, &_Ch + 1, _Mid2))
448  { // test result of single wide-char conversion
449  case _Mybase::noconv:
450  return ((int)(_Wchars + (_Last1 - _First1)));
451 
452  case _Mybase::ok:
453  if (_Mid2 == &_Ch + 1)
454  ++_Wchars; // replacement do_in might not convert one
455  _First1 = _Mid1;
456  break;
457 
458  default:
459  return ((int)_Wchars); // error or partial
460  }
461  }
462 
463  return ((int)_Wchars);
464  }
char _Byte
Definition: codecvt:245
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:260
_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
_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_utf16< _Elem, _Mymax, _Mymode >::do_max_length ( ) const
inlineprotectedvirtual

Reimplemented from codecvt_base.

472  { // return maximum length required for a conversion
473  return ((_Mymode & (consume_header | generate_header)) != 0
474  ? 3 * _Bytes_per_word : 6 * _Bytes_per_word);
475  }
Definition: codecvt:25
Definition: codecvt:24
Definition: codecvt:241
template<class _Elem , unsigned long _Mymax = 0x10ffff, codecvt_mode _Mymode = (codecvt_mode)0>
virtual result __CLR_OR_THIS_CALL codecvt_utf16< _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 >.

341  { // convert [_First1, _Last1) to bytes [_First2, _Last)
342  char *_Pstate = (char *)&_State;
343  _Mid1 = _First1;
344  _Mid2 = _First2;
345 
346  if (*_Pstate == 0)
347  { // determine endianness once, maybe generate header
348  *_Pstate = (_Mymode & little_endian) != 0
350  if ((_Mymode & generate_header) == 0)
351  ;
352  else if (_Last2 - _Mid2 < 3 * _Bytes_per_word)
353  return (_Mybase::partial); // not enough room for all
354  else if (*_Pstate == _LITTLE_FIRST)
355  { // put header LS byte first
356  *_Mid2++ = (_Byte)(unsigned char)0xff;
357  *_Mid2++ = (_Byte)(unsigned char)0xfe;
358  }
359  else
360  { // put header MS byte first
361  *_Mid2++ = (_Byte)(unsigned char)0xfe;
362  *_Mid2++ = (_Byte)(unsigned char)0xff;
363  }
364  }
365 
366  for (; _Mid1 != _Last1 && _Bytes_per_word <= _Last2 - _Mid2; )
367  { // convert and put a wide char
368  bool _Extra = false;
369  unsigned long _Ch = (unsigned long)*_Mid1++;
370 
371  if ((_Mymax < 0x10ffff ? _Mymax : 0x10ffff) < _Ch)
372  return (_Mybase::error); // value too large
373  else if (_Ch <= 0xffff)
374  { // one word, can't be code for first of two
375  if (0xd800 <= _Ch && _Ch < 0xdc00)
376  return (_Mybase::error);
377  }
378  else if (_Last2 - _Mid2 < 2 * _Bytes_per_word)
379  { // not enough room for two-word output, back up
380  --_Mid1;
381  return (_Mybase::partial);
382  }
383  else
384  _Extra = true;
385 
386  if (*_Pstate == _LITTLE_FIRST)
387  if (!_Extra)
388  { // put a single word LS byte first
389  *_Mid2++ = (_Byte)_Ch;
390  *_Mid2++ = (_Byte)(_Ch >> 8);
391  }
392  else
393  { // put a pair of words LS byte first
394  unsigned short _Ch0 = (unsigned short)(0xd800
395  | (unsigned short)(_Ch >> 10) - 0x0040);
396  *_Mid2++ = (_Byte)_Ch0;
397  *_Mid2++ = (_Byte)(_Ch0 >> 8);
398 
399  _Ch0 = (unsigned short)(0xdc00
400  | ((unsigned short)_Ch & 0x03ff));
401  *_Mid2++ = (_Byte)_Ch0;
402  *_Mid2++ = (_Byte)(_Ch0 >> 8);
403  }
404  else
405  if (!_Extra)
406  { // put a single word MS byte first
407  *_Mid2++ = (_Byte)(_Ch >> 8);
408  *_Mid2++ = (_Byte)_Ch;
409  }
410  else
411  { // put a pair of words MS byte first
412  unsigned short _Ch0 = (unsigned short)(0xd800
413  | (unsigned short)(_Ch >> 10) - 0x0040);
414  *_Mid2++ = (_Byte)(_Ch0 >> 8);
415  *_Mid2++ = (_Byte)_Ch0;
416 
417  _Ch0 = (unsigned short)(0xdc00
418  | ((unsigned short)_Ch & 0x03ff));
419  *_Mid2++ = (_Byte)(_Ch0 >> 8);
420  *_Mid2++ = (_Byte)_Ch0;
421  }
422  }
423 
424  return (_First1 == _Mid1 ? _Mybase::partial : _Mybase::ok);
425  }
char _Byte
Definition: codecvt:245
Definition: codecvt:25
_In_ long
Definition: corecrt_wstdlib.h:88
Definition: codecvt:26
Definition: xlocale:759
#define _BIG_FIRST
Definition: codecvt:20
_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: codecvt:241
#define _LITTLE_FIRST
Definition: codecvt:19
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_utf16< _Elem, _Mymax, _Mymode >::do_unshift ( _Statype ,
_Byte _First2,
_Byte ,
_Byte *&  _Mid2 
) const
inlineprotectedvirtual

Reimplemented from codecvt< _Elem, char, _Statype >.

429  { // generate bytes to return to default shift state
430  _Mid2 = _First2;
431  return (_Mybase::ok);
432  }
Definition: xlocale:759

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