Simplify is_utf8_enabled

This commit is contained in:
Victor Zverovich 2024-08-29 14:39:26 -07:00
parent e582d377c2
commit 7477dda28d

View File

@ -478,12 +478,7 @@ struct is_std_string_like<T, void_t<decltype(std::declval<T>().find_first_of(
const typename T::value_type*> {};
// Returns true iff the literal encoding is UTF-8.
constexpr auto is_utf8_enabled() -> bool {
// Avoid an MSVC sign extension bug: https://github.com/fmtlib/fmt/pull/2297.
using uchar = unsigned char;
return sizeof("\u00A7") == 3 && uchar("\u00A7"[0]) == 0xC2 &&
uchar("\u00A7"[1]) == 0xA7;
}
constexpr auto is_utf8_enabled() -> bool { return "\u00A7"[1] == '\xA7'; }
constexpr auto use_utf8() -> bool {
return !FMT_MSC_VERSION || is_utf8_enabled();
}