diff --git a/include/fmt/core.h b/include/fmt/core.h index 9862b85c..9c435f53 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1535,7 +1535,8 @@ inline void print(std::FILE* f, const S& format_str, Args&&... args) { /** \rst - Prints formatted data to ``stdout``. + Formats ``args`` according to specifications in ``format_str`` and writes the + output to ``stdout``. **Example**:: diff --git a/include/fmt/format.h b/include/fmt/format.h index 3f4d4c78..e1b34d19 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -559,8 +559,7 @@ class buffer_range : public internal::output_range< : internal::output_range(std::back_inserter(buf)) {} }; -// A UTF-8 string view. -class u8string_view : public basic_string_view { +class FMT_DEPRECATED u8string_view : public basic_string_view { public: u8string_view(const char* s) : basic_string_view(reinterpret_cast(s)) {} @@ -571,8 +570,8 @@ class u8string_view : public basic_string_view { #if FMT_USE_USER_DEFINED_LITERALS inline namespace literals { -inline u8string_view operator"" _u(const char* s, std::size_t n) { - return {s, n}; +inline basic_string_view operator"" _u(const char* s, std::size_t n) { + return {reinterpret_cast(s), n}; } } // namespace literals #endif diff --git a/test/format-impl-test.cc b/test/format-impl-test.cc index e4f19810..34814967 100644 --- a/test/format-impl-test.cc +++ b/test/format-impl-test.cc @@ -427,7 +427,11 @@ TEST(FormatTest, FormatErrorCode) { } TEST(FormatTest, CountCodePoints) { - EXPECT_EQ(4, fmt::internal::count_code_points(fmt::u8string_view("ёжик"))); +#ifndef __cpp_char8_t + using fmt::char8_t; +#endif + EXPECT_EQ(4, fmt::internal::count_code_points( + fmt::basic_string_view(reinterpret_cast("ёжик")))); } // Tests fmt::internal::count_digits for integer type Int. diff --git a/test/format-test.cc b/test/format-test.cc index 050a442e..6eee9fe6 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -2467,27 +2467,10 @@ TEST(FormatTest, FmtStringInTemplate) { using fmt::char8_t; #endif -TEST(FormatTest, ConstructU8StringViewFromCString) { - fmt::u8string_view s("ab"); - EXPECT_EQ(s.size(), 2u); - const char8_t* data = s.data(); - EXPECT_EQ(data[0], 'a'); - EXPECT_EQ(data[1], 'b'); -} - -TEST(FormatTest, ConstructU8StringViewFromDataAndSize) { - fmt::u8string_view s("foobar", 3); - EXPECT_EQ(s.size(), 3u); - const char8_t* data = s.data(); - EXPECT_EQ(data[0], 'f'); - EXPECT_EQ(data[1], 'o'); - EXPECT_EQ(data[2], 'o'); -} - #if FMT_USE_USER_DEFINED_LITERALS TEST(FormatTest, U8StringViewLiteral) { using namespace fmt::literals; - fmt::u8string_view s = "ab"_u; + fmt::basic_string_view s = "ab"_u; EXPECT_EQ(s.size(), 2u); const char8_t* data = s.data(); EXPECT_EQ(data[0], 'a'); @@ -2496,10 +2479,6 @@ TEST(FormatTest, U8StringViewLiteral) { } #endif -TEST(FormatTest, FormatU8String) { - EXPECT_EQ(format(fmt::u8string_view("{}"), 42), fmt::u8string_view("42")); -} - TEST(FormatTest, EmphasisNonHeaderOnly) { // Ensure this compiles even if FMT_HEADER_ONLY is not defined. EXPECT_EQ(fmt::format(fmt::emphasis::bold, "bold error"),