mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-19 11:14:41 +00:00
Simplify is_utf8_enabled
This commit is contained in:
parent
e582d377c2
commit
7477dda28d
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user