Describes a failure to encode, decode, transcode, or count, for four core various reasons.
This does not cover specific failures, like if a sequence was overlong (e.g., UTF-8) or if an encode operation produced an uunpaired surrogate value (e.g. UTF-16).
The okay status; everything is fine.
This does not necessarily mean an error handler was not called. An error handler can set the error code to ztd::text::encoding_error::ok after performing corrective action: see ztd::text::replacement_handler_t for an example.
Input contains ill-formed sequences. This means there were available units of input to read, but what was read resulted in an error.
Input contains incomplete sequences. This means that the input was exhausted, without finding an invalid sequence, and therefore more input may be required.
Depending on context, this may or may not be an error in your use case (e.g., reading part of an incomplete network buffer and waiting for more). See ztd::text::basic_incomplete_handler as a way to aid with this use case.
Output cannot receive the successfully encoded or decoded sequence. This means that, while there were no invalid or incomplete sequences in the input, the output ran out of space to receive it.
Provide a bigger storage area or guarantee that it meets the minimum required size for potential output. This can be queried for an encoding by using ztd::text::max_code_points_v<the_encoding> for code points, and ztd::text::max_code_units_v<the_encoding> for code units.
- enumerator ok
inline constexpr ::std::string_view ztd::text::to_name(encoding_error __error_code)
Converts an encoding_error to a string value.
If a value outside of the allowed encoding_error is passed, then undefined behavior happens.
A null-terminated string_view to the data.