In UTF32, a code point is 4 bytes, but fmt only keeps 2 bytes when parsing it into fill:
|
template <typename Char> constexpr auto fill_unit() const -> Char { |
|
using uchar = unsigned char; |
|
return static_cast<Char>(static_cast<uchar>(fill_data_[0]) | |
|
(static_cast<uchar>(fill_data_[1]) << 8)); |
|
} |
|
|
|
FMT_CONSTEXPR void set_fill(char c) { |
|
fill_data_[0] = c; |
|
set_fill_size(1); |
|
} |
|
|
|
template <typename Char> |
|
FMT_CONSTEXPR void set_fill(basic_string_view<Char> s) { |
|
auto size = s.size(); |
|
set_fill_size(size); |
|
if (size == 1) { |
|
unsigned uchar = static_cast<detail::unsigned_char<Char>>(s[0]); |
|
fill_data_[0] = static_cast<char>(uchar); |
|
fill_data_[1] = static_cast<char>(uchar >> 8); |
|
return; |
|
} |
|
FMT_ASSERT(size <= max_fill_size, "invalid fill"); |
|
for (size_t i = 0; i < size; ++i) |
|
fill_data_[i & 3] = static_cast<char>(s[i]); |
|
} |
|
}; |
meanwhile, UTF8 can keep 4 bytes for fill.
repro: https://godbolt.org/z/qfTKe6W6c
In UTF32, a code point is 4 bytes, but fmt only keeps 2 bytes when parsing it into fill:
fmt/include/fmt/base.h
Lines 800 to 825 in cc2ba8f
meanwhile, UTF8 can keep 4 bytes for fill.
repro: https://godbolt.org/z/qfTKe6W6c