Encoding

template<EncodingForm Encoding>
using code_unit_t

The type of the code units used by Encoding.

template<EncodingForm Encoding>
constexpr auto max_width_v

The maximum number of code units needed by Encoding to represent one code point.

template<EncodingForm Encoding>
constexpr auto replacement_character_v

The character used to replace invalid input when replace_errors is used for an encoding operation.

Note

Decoding always uses U+FFFD ʀᴇᴘʟᴀᴄᴇᴍᴇɴᴛ ᴄʜᴀʀᴀᴄᴛᴇʀ to replace errors.

template<EncodingForm Encoding>
using coding_state_t

The type of the state used by Encoding. For stateless encoding forms this is an empty type.

template<EncodingForm Encoding>
using is_stateless

Derives from std::true_type if Encoding is stateless; from std::false_type otherwise.

template<EncodingForm Encoding>
constexpr bool is_stateless_v

True if Encoding is stateless; false otherwise.

template<EncodingForm Encoding>
coded_character_t<Encoding> encode_one(code_point u, coding_state_t<Encoding> &state)

Warning

This part of the interface is still being worked out; it is likely to change signficantly or to be removed before the next release.

Encodes u according to Encoding.

Parameters:
  • u – the code point to be encoded
  • state – the current encoding state; it is modified according to the encoding performed
Returns:

a range of the code units that encode u

Throws:

encode_error when the input cannot be encoded by Encoding

template<EncodingForm Encoding>
using coded_character_t

Range of the code units that encode one code point.

template<EncodingForm Encoding, ForwardRange Rng, EncodeErrorHandler Handler>
auto encode(Rng rng, Handler &&handler)

Encodes a range of code points, according to Encoding.

Parameters:
  • rng – The range of code points to encode
  • handler – The strategy for error handling
Returns:

a range of the code units that encode the code points in rng

Validation:

as performed by Encoding; errors are handled by handler

template<EncodingForm Encoding, ForwardIterator It, Sentinel St>
std::pair<code_point, It> decode_one(It first, St last, coding_state_t<Encoding> &state)

Warning

This part of the interface is still being worked out; it is likely to change signficantly or to be removed before the next release.

Decodes the first code point from the range [first, last), according to Encoding.

Parameters:
  • first – an iterator to the first code unit to be decoded
  • last – an iterator/sentinel to the end of the range of code units
  • state – the current decoding state; it is modified according to the decoding performed
Returns:

a pair of the decoded code point and an iterator to first code unit of the next encoded code point

Throws:

decode_error when the input cannot be decoded by Encoding

template<EncodingForm Encoding, ForwardRange Rng, EncodeErrorHandler Handler>
auto decode(Rng rng, Handler &&handler)

Decodes a range of code points, according to Encoding.

Parameters:
  • rng – The range of code points to encode
  • handler – The strategy for error handling
Returns:

a range of the code points that the code units in rng represent

Validation:

as performed by Encoding; errors are handled by handler

template<EncodingForm Encoding>
using coded_character

A container type for the code units that encode a single code point according to Encoding.