mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-24 03:17:53 +00:00
Fix handling of unsigned char strings in printf
This commit is contained in:
parent
63b23e786a
commit
7d01859ef1
@ -972,6 +972,14 @@ template <typename Context> struct arg_mapper {
|
||||
static_assert(std::is_same<char_type, char>::value, "invalid string type");
|
||||
return reinterpret_cast<const char*>(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; }
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user