mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-17 15:02:24 +00: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: b4d13d060a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/434
Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 6 additions and 1 deletions
|
@ -888,7 +888,12 @@ ErrorOr<void> Formatter<T>::format(FormatBuilder& builder, T value)
|
||||||
m_mode = Mode::String;
|
m_mode = Mode::String;
|
||||||
|
|
||||||
Formatter<StringView> formatter { *this };
|
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())
|
if (m_precision.has_value())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue