mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-09 12:50:05 +00:00
Enable Unicode support by default
This commit is contained in:
parent
1dc71f21ea
commit
b7809f91e2
@ -341,6 +341,12 @@ endif ()
|
||||
add_library(fmt-header-only INTERFACE)
|
||||
add_library(fmt::fmt-header-only ALIAS fmt-header-only)
|
||||
|
||||
if (MSVC)
|
||||
# Unicode support requires compiling with /utf-8.
|
||||
target_compile_options(fmt PUBLIC /utf-8)
|
||||
target_compile_options(fmt-header-only INTERFACE /utf-8)
|
||||
endif ()
|
||||
|
||||
target_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY=1)
|
||||
target_compile_features(fmt-header-only INTERFACE cxx_std_11)
|
||||
|
||||
|
@ -424,8 +424,11 @@ FMT_CONSTEXPR inline auto is_utf8() -> bool {
|
||||
FMT_MSC_WARNING(suppress : 4566) constexpr unsigned char section[] = "\u00A7";
|
||||
// Avoid an MSVC sign extension bug: https://github.com/fmtlib/fmt/pull/2297.
|
||||
using uchar = unsigned char;
|
||||
return FMT_UNICODE || (sizeof(section) == 3 && uchar(section[0]) == 0xC2 &&
|
||||
uchar(section[1]) == 0xA7);
|
||||
constexpr bool utf8 = sizeof(section) == 3 && uchar(section[0]) == 0xC2 &&
|
||||
uchar(section[1]) == 0xA7;
|
||||
static_assert(utf8 || !FMT_MSC_VERSION,
|
||||
"Unicode support requires compiling with /utf-8");
|
||||
return FMT_UNICODE || utf8;
|
||||
}
|
||||
|
||||
template <typename Char> FMT_CONSTEXPR auto length(const Char* s) -> size_t {
|
||||
|
@ -146,6 +146,9 @@ if (NOT MSVC_STATIC_RUNTIME)
|
||||
if (FMT_PEDANTIC)
|
||||
target_compile_options(posix-mock-test PRIVATE ${PEDANTIC_COMPILE_FLAGS})
|
||||
endif ()
|
||||
if (MSVC)
|
||||
target_compile_options(posix-mock-test PRIVATE /utf-8)
|
||||
endif ()
|
||||
add_test(NAME posix-mock-test COMMAND posix-mock-test)
|
||||
add_fmt_test(os-test)
|
||||
endif ()
|
||||
|
Loading…
Reference in New Issue
Block a user