is_(bitwise_)transcoding_compatible

This classification checks if two encodings are compatible, or bitwise compatible. The heuristic for normal compatibility is simple:

  • it checks if the two encodings are identical;

  • it checks if the two encodings are near-identical derivations of one another (e.g., UTF-8 being converted to MUTF-8 (but not in the other direction)); or,

  • it checks if the code point types between the two encodings are the same, or if they are both some form of unicode code point.

This type specifically uses the first type as the From encoding (e.g., the one to decode the input code unit sequence) and the second type as the To encoding (e.g., the one to encode the intermediate decoded code point sequence).

Note

User Specializations: ✔️ Okay! You can add other types to this classification by specializing the class template to a definition that derives from std::true_type, or turn it off explicitly by having a definition that derives from std::false_type. Note that specializing any type not explicitly marked with this notice is ☢️☢️Undefined Behavior☢️☢️.

Warning

⚠️ Specializing this type for types which are not either transcoding compatible or bitwise compatible can result in ☢️☢️Undefined Behavior☢️☢️ within the library.

template<typename _From, typename _To>
class is_transcoding_compatible : public std::integral_constant<bool, __txt_detail::__is_bitwise_transcoding_compatible_v<_From, _To>>

Checks whether or not the specified _From encoding can be transcoded to the _To encoding without invoking a lossy conversion when using the intermediate code points.

Remark

First, it checks if the encodings are bitwise compatible with one another (e.g., transcoding ASCII to UTF-8). If that is not the case, then it checks if the two encodings are just identical. Finally, it checks if the code point types are the same or if it’s putting unicode scalar values into unicode code points (which is valid one way, but not the other way since scalar values do not allow surrogates). If none of these are true, then, the intermediate code point likely cannot convert between the two losslessly.

Template Parameters:
  • _From – The encoding that is going to decode the input code units into the intermediate code points.

  • _To – The encoding that is going to encode the intermediate code points into the final code units.

template<typename _From, typename _To>
constexpr bool ztd::text::is_transcoding_compatible_v = is_transcoding_compatible<_To, _From>::value

An alias of the inner value for ztd::text::is_transcoding_compatible.

template<typename _From, typename _To>
class is_bitwise_transcoding_compatible : public std::integral_constant<bool, __txt_detail::__is_bitwise_transcoding_compatible_v<_From, _To>>

Checks whether or not the specified _From encoding can be transcoded to the _To encoding without by form of bit copying.

Template Parameters:
  • _From – The encoding that is going to decode the input code units into the intermediate code points.

  • _To – The encoding that is going to encode the intermediate code points into the final code units.

template<typename _From, typename _To>
constexpr bool ztd::text::is_bitwise_transcoding_compatible_v = is_bitwise_transcoding_compatible<::ztd::remove_cvref_t<_From>, ::ztd::remove_cvref_t<_To>>::value

An alias of the inner value for ztd::text::is_transcoding_compatible.