Converts between character encodings. More...
Inherits codecvt< T, B, Pt::MBState >.
|External character type. |
|Internal character type. |
|Conversion state type. |
|TextCodec (std::size_t ref=0)|
|Constructs with reference count. More...|
|bool||always_noconv () const|
|Returns true if no conversion is required. |
|int||encoding () const|
|Returns the encoding rate. |
|result||in (MBState &s, const ByteT *fbeg, const ByteT *fend, const ByteT *&fnext, CharT *tbeg, CharT *tend, CharT *&tnext) const|
|Decodes a character sequence. |
|int||length (MBState &state, const ByteT *from, const ByteT *end, std::size_t max) const|
|Returns the number of the decoded characters. |
|int||max_length () const|
|Maximum length of an external sequence if one character is encoded. |
|result||out (MBState &state, const CharT *fbeg, const CharT *fend, const CharT *&fnext, ByteT *tbeg, ByteT *tend, ByteT *&tnext) const|
|Encodes a character sequence. |
|result||unshift (MBState &state, ByteT *to, ByteT *to_end, ByteT *&to_next) const|
|Unshifts a character sequence. |
A Pt::TextCodec is used by the text streams and buffers for coding and encoding external byte sequences, hence the name codec. It implements the std::codecvt facet interface, however not all systems provide the std::locale facilities. Codecs are stateless, which means that one codec can be used with multiple text streams. A TextCodec is constructed with a reference counter that indicates whether the stream manages the lifetime of the codec. If that value is 0, as it is the case if the TextCodec is default constructed, the text stream will delete the codec.
Therefore, a default constructed TextCodec has to be cretaed with new, as it is the rule for all localization facets. This can be avoided by passing a value different from 0 to the codecs constructor, in which case the codec must exist at least as long as the stream that uses it:
|TextCodec||(||std::size_t||ref = ||)|
If ref is 0 the stream, stream buffer or locale deletes the facet.