mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
AK: Add a basic formatter for wchar_t
This commit is contained in:
parent
4ef3ed4ba3
commit
67a579aab0
Notes:
sideshowbarker
2024-07-18 03:09:55 +09:00
Author: https://github.com/timschumi
Commit: 67a579aab0
Pull-request: https://github.com/SerenityOS/serenity/pull/10170
Reviewed-by: https://github.com/BertalanD ✅
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/IdanHo
Reviewed-by: https://github.com/kleinesfilmroellchen
3 changed files with 31 additions and 0 deletions
|
@ -688,6 +688,19 @@ void Formatter<char>::format(FormatBuilder& builder, char value)
|
|||
return formatter.format(builder, { &value, 1 });
|
||||
}
|
||||
}
|
||||
void Formatter<wchar_t>::format(FormatBuilder& builder, wchar_t value)
|
||||
{
|
||||
if (m_mode == Mode::Binary || m_mode == Mode::BinaryUppercase || m_mode == Mode::Decimal || m_mode == Mode::Octal || m_mode == Mode::Hexadecimal || m_mode == Mode::HexadecimalUppercase) {
|
||||
Formatter<u32> formatter { *this };
|
||||
return formatter.format(builder, static_cast<u32>(value));
|
||||
} else {
|
||||
StringBuilder codepoint;
|
||||
codepoint.append_code_point(value);
|
||||
|
||||
Formatter<StringView> formatter { *this };
|
||||
return formatter.format(builder, codepoint.to_string());
|
||||
}
|
||||
}
|
||||
void Formatter<bool>::format(FormatBuilder& builder, bool value)
|
||||
{
|
||||
if (m_mode == Mode::Binary || m_mode == Mode::BinaryUppercase || m_mode == Mode::Decimal || m_mode == Mode::Octal || m_mode == Mode::Hexadecimal || m_mode == Mode::HexadecimalUppercase) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue