Export (0) Print
Expand All

codecvt Class

A template class that describes an object that can serve as a locale facet. It 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 locale::facet, 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 template class describes an object that can serve as a locale facet, to control conversions between a sequence of values of type CharType and a sequence of values of type Byte. The class StateType characterizes the transformation -- and an object of class StateType stores any necessary state information during a conversion.

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

The template versions of do_in and do_out always return codecvt_base::noconv.

The Standard C++ Library defines several explicit specializations:

template<>

codecvt<wchar_t, char, mbstate_t>

converts between wchar_t and char sequences.

template<>

codecvt<char16_t, char, mbstate_t>

converts between char16_t sequences encoded as UTF-16 and char sequences encoded as UTF-8.

template<>

codecvt<char32_t, char, mbstate_t>

converts between char32_t sequences encoded as UTF-32 (UCS-4) and char sequences encoded as UTF-8.

codecvt

The constructor for objects of class codecvt that serves as a locale facet to handle conversions.

extern_type

A character type that is used for external representations.

intern_type

A character type that is used for internal representations.

state_type

A character type that is used to represent intermediate states during conversions between internal and external representations.

always_noconv

Tests whether no conversions need be done.

do_always_noconv

A virtual function called to test whether no conversions need be done.

do_encoding

A virtual function that tests if the encoding of the Byte stream is state dependent, whether the ratio between the Bytes used and the CharTypes produced is constant, and, if so, determines the value of that ratio.

do_in

A virtual function called to convert a sequence of internal Bytes to a sequence of external CharTypes.

do_length

A virtual function that determines how many Bytes from a given sequence of external Bytes produce not more than a given number of internal CharTypes and returns that number of Bytes.

do_max_length

A virtual function that returns the maximum number of external Bytes necessary to produce one internal CharType.

do_out

A virtual function called to convert a sequence of internal CharTypes to a sequence of external Bytes.

do_unshift

A virtual function called to provide the Bytes needed in a state-dependent conversion to complete the last character in a sequence of Bytes.

encoding

Tests if the encoding of the Byte stream is state dependent, whether the ratio between the Bytes used and the CharTypes produced is constant, and, if so, determines the value of that ratio.

in

Converts an external representation of a sequence of Bytes to an internal representation of a sequence of CharTypes.

length

Determines how many Bytes from a given sequence of external Bytes produce not more than a given number of internal CharTypes and returns that number of Bytes.

max_length

Returns the maximum number of external Bytes necessary to produce one internal CharType.

out

Converts a sequence of internal CharTypes to a sequence of external Bytes.

unshift

Provides the external Bytes needed in a state-dependent conversion to complete the last character in the sequence of Bytes.

Header: <locale>

Namespace: std

Show:
© 2014 Microsoft