mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-27 04:39:44 +01:00
unicode_to_utf8 -> to_utf8 since both sides of conversion are Unicode
This commit is contained in:
@@ -377,8 +377,8 @@ auto write_encoded_tm_str(OutputIt out, string_view in, const std::locale& loc)
|
||||
unit_t unit;
|
||||
write_codecvt(unit, in, loc);
|
||||
// In UTF-8 is used one to four one-byte code units.
|
||||
unicode_to_utf8<code_unit, basic_memory_buffer<char, unit_t::max_size * 4>>
|
||||
u;
|
||||
auto u =
|
||||
to_utf8<code_unit, basic_memory_buffer<char, unit_t::max_size * 4>>();
|
||||
if (!u.convert({unit.buf, to_unsigned(unit.end - unit.buf)}))
|
||||
FMT_THROW(format_error("failed to format time"));
|
||||
return copy_str<char>(u.c_str(), u.c_str() + u.size(), out);
|
||||
|
||||
@@ -1420,13 +1420,13 @@ class utf8_to_utf16 {
|
||||
|
||||
// A converter from UTF-16/UTF-32 (host endian) to UTF-8.
|
||||
template <typename WChar, typename Buffer = memory_buffer>
|
||||
class unicode_to_utf8 {
|
||||
class to_utf8 {
|
||||
private:
|
||||
Buffer buffer_;
|
||||
|
||||
public:
|
||||
unicode_to_utf8() {}
|
||||
explicit unicode_to_utf8(basic_string_view<WChar> s) {
|
||||
to_utf8() {}
|
||||
explicit to_utf8(basic_string_view<WChar> s) {
|
||||
static_assert(sizeof(WChar) == 2 || sizeof(WChar) == 4,
|
||||
"Expect utf16 or utf32");
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ inline void write_escaped_path<char>(memory_buffer& quoted,
|
||||
auto buf = basic_memory_buffer<wchar_t>();
|
||||
write_escaped_string<wchar_t>(std::back_inserter(buf), p.native());
|
||||
// Convert UTF-16 to UTF-8.
|
||||
if (!unicode_to_utf8<wchar_t>::convert(quoted, {buf.data(), buf.size()}))
|
||||
if (!to_utf8<wchar_t>::convert(quoted, {buf.data(), buf.size()}))
|
||||
FMT_THROW(std::runtime_error("invalid utf16"));
|
||||
}
|
||||
# endif
|
||||
|
||||
Reference in New Issue
Block a user