diff --git a/include/fmt/core.h b/include/fmt/core.h index 6df2875acfc2..dc10722bffc3 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -972,6 +972,14 @@ template struct arg_mapper { static_assert(std::is_same::value, "invalid string type"); return reinterpret_cast(val); } + FMT_CONSTEXPR const char* map(signed char* val) { + const auto* const_val = val; + return map(const_val); + } + FMT_CONSTEXPR const char* map(unsigned char* val) { + const auto* const_val = val; + return map(const_val); + } FMT_CONSTEXPR const void* map(void* val) { return val; } FMT_CONSTEXPR const void* map(const void* val) { return val; } diff --git a/test/printf-test.cc b/test/printf-test.cc index 5aaa27b13ef0..545e02aab801 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -447,6 +447,12 @@ TEST(PrintfTest, String) { EXPECT_PRINTF(L" (null)", L"%10s", null_wstr); } +TEST(PrintfTest, UCharString) { + unsigned char str[] = "test"; + unsigned char* pstr = str; + EXPECT_EQ("test", fmt::sprintf("%s", pstr)); +} + TEST(PrintfTest, Pointer) { int n; void* p = &n;