STL/codecvt

Материал из Wiki.crossplatform.ru

Версия от 07:56, 12 ноября 2011; ViGOur (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

codecvt Class

A template class that describes an object that can serve as a locale facet that is able to control conversions between a sequence of values used to encode characters within the program and a sequence of values used to encode characters outside the program.

template <
   class CharType,
   class Byte,
   class StateType,
> 
class codecvt : public codecvt_base

CharType

  • The type used within a program to encode characters.

Byte

  • A type used to encode characters outside a program.

StateType

  • A type that can be used to represent intermediate states of a conversion between internal and external types of character representations.

The internal encoding uses a representation with a fixed number of bytes per character, usually either type char or type wchar_t.

As with any locale facet, the static object ID has an initial stored value of zero. The first attempt to access its stored value stores a unique positive value in id.

The template versions of do_in and do_out always return codecvt_base::noconv. The Standard C++ Library defines an explicit specialization, however, that is more useful:

template<> codecvt<wchar_t, char, mbstate_t>

which converts between wchar_t and char sequences.