Fix handling of char

This commit is contained in:
Victor Zverovich
2022-12-30 08:59:12 -08:00
parent 8fe4d97d5e
commit 32190859ec
4 changed files with 11 additions and 14 deletions

View File

@@ -1898,9 +1898,12 @@ template <typename Char, typename OutputIt>
FMT_CONSTEXPR auto write(OutputIt out, Char value,
const format_specs<Char>& specs, locale_ref loc = {})
-> OutputIt {
// char is formatted as unsigned char for consistency across platforms.
using unsigned_type =
conditional_t<std::is_same<Char, char>::value, unsigned char, unsigned>;
return check_char_specs(specs)
? write_char(out, value, specs)
: write(out, static_cast<int>(value), specs, loc);
: write(out, static_cast<unsigned_type>(value), specs, loc);
}
// Data for write_int that doesn't depend on output iterator type. It is used to