<codecvt>[added with C++11]
codecvt_mode
· codecvt_utf16
· codecvt_utf8
· codecvt_utf8_utf16
Include the header <codecvt>
to define several template classes that describe objects based
on template class
codecvt.
These objects can serve as
locale facets that
control conversions between a sequence of values of type Elem
and a sequence of values of type char.
namespace std {
enum codecvt_mode;
template<class Elem, unsigned long Maxcode = 0x10ffff,
codecvt_mode Mode = (codecvt_mode)0>
class codecvt_utf16;
template<class Elem, unsigned long Maxcode = 0x10ffff,
codecvt_mode Mode = (codecvt_mode)0>
class codecvt_utf8;
template<class Elem, unsigned long Maxcode = 0x10ffff,
codecvt_mode Mode = (codecvt_mode)0>
class codecvt_utf8_utf16;
} // namespace std
The locale facets declared in this header convert between several character encodings. For wide characters (stored within the program in fixed-size integers):
For byte streams (stored in a file, transmitted as a byte sequence, or
stored within the program in an array of char):
codecvt_modenamespace std {
enum codecvt_mode {
consume_header = 4,
generate_header = 2,
little_endian = 1};
The enumeration defines three constants that supply configuration information to the locale facets declared in this header:
consume_header -- to consume an initial header
sequence when reading a multibyte sequence and determine the endianness
of the subsequent multibyte sequence to be readgenerate_header -- to generate an initial header
sequence when writing a multibyte sequence to advertise the endianness
of the subsequent multibyte sequence to be writtenlittle_endian -- to generate a multibyte sequence
in little-endian order, as opposed to the default big-endian orderThese constants can be ORed together in arbitrary combinations.
codecvt_utf16template<class Elem, unsigned long Maxcode = 0x10ffff,
codecvt_mode Mode = (codecvt_mode)0>
class codecvt_utf16;
The locale facet converts between wide characters of type Elem,
encoded as UCS-2 or UCS-4, and a byte stream encoded as UTF-16LE
if Mode & little_endian or UTF-16BE otherwise. The byte
stream should be written to a binary file; it can be corrupted if
written to a text file.
codecvt_utf8template<class Elem, unsigned long Maxcode = 0x10ffff,
codecvt_mode Mode = (codecvt_mode)0>
class codecvt_utf8;
The locale facet converts between wide characters of type Elem,
encoded as UCS-2 or UCS-4, and a byte stream encoded as UTF-8. The byte
stream can be written to either a binary file or a text file.
codecvt_utf8_utf16template<class Elem, unsigned long Maxcode = 0x10ffff,
codecvt_mode Mode = (codecvt_mode)0>
class codecvt_utf8_utf16;
The locale facet converts between wide characters of type Elem,
encoded as UTF-16, and a byte stream encoded as UTF-8. The byte
stream can be written to either a binary file or a text file.
See also the Table of Contents and the Index.
Copyright © 1992-2013 by P.J. Plauger. All rights reserved.