mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
AK: Fix {:c} formatter for big-endian
This commit is contained in:
parent
1bc44376c0
commit
b4d13d060a
Notes:
sideshowbarker
2024-07-17 03:18:29 +09:00
Author: https://github.com/sideeffect42 Commit: https://github.com/LadybirdBrowser/ladybird/commit/b4d13d060a Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/434 Reviewed-by: https://github.com/ADKaster ✅
@ -888,7 +888,12 @@ ErrorOr<void> Formatter<T>::format(FormatBuilder& builder, T value)
|
||||
m_mode = Mode::String;
|
||||
|
||||
Formatter<StringView> formatter { *this };
|
||||
return formatter.format(builder, StringView { reinterpret_cast<char const*>(&value), 1 });
|
||||
|
||||
// convert value to single byte, important for big-endian because the LSB is the last byte.
|
||||
VERIFY(value >= 0 && value <= 127);
|
||||
char const c = (value & 0x7f);
|
||||
|
||||
return formatter.format(builder, StringView { &c, 1 });
|
||||
}
|
||||
|
||||
if (m_precision.has_value())
|
||||
|
Loading…
Reference in New Issue
Block a user