mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02:00
AK: Add option to the string formatter to use a digit separator
`vformat()` can now accept format specifiers of the form
{:'[numeric-type]}. This will output a number with a comma separator
every 3 digits.
For example:
`dbgln("{:'d}", 9999999);` will output 9,999,999.
Binary, octal and hexadecimal numbers can also use this feature, for
example:
`dbgln("{:'x}", 0xffffffff);` will output ff,fff,fff.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
605b4e96a8
commit
72ea046b68
Notes:
sideshowbarker
2024-07-17 01:04:03 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/72ea046b68 Pull-request: https://github.com/SerenityOS/serenity/pull/17739 Reviewed-by: https://github.com/gmta
@@ -70,7 +70,7 @@ struct AK::Formatter<Crypto::Hash::Digest<DigestS>> : StandardFormatter {
|
||||
for (size_t i = 0; i < digest.Size; ++i) {
|
||||
if (i > 0 && i % 4 == 0)
|
||||
TRY(builder.put_padding('-', 1));
|
||||
TRY(builder.put_u64(digest.data[i], 16, false, false, true, FormatBuilder::Align::Right, 2));
|
||||
TRY(builder.put_u64(digest.data[i], 16, false, false, true, false, FormatBuilder::Align::Right, 2));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user