mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:37:34 +00:00
LibWeb: Add to_ascii_upper_case() from the Infra spec
https://infra.spec.whatwg.org/#ascii-uppercase
This commit is contained in:
parent
2c1e15bd3b
commit
31a9bd2bfd
2 changed files with 15 additions and 0 deletions
|
@ -120,4 +120,18 @@ ErrorOr<String> to_ascii_lower_case(StringView string)
|
|||
return string_builder.to_string();
|
||||
}
|
||||
|
||||
// https://infra.spec.whatwg.org/#ascii-uppercase
|
||||
ErrorOr<String> to_ascii_upper_case(StringView string)
|
||||
{
|
||||
// To ASCII uppercase a string, replace all ASCII lower alphas in the string with their
|
||||
// corresponding code point in ASCII upper alpha.
|
||||
StringBuilder string_builder;
|
||||
auto utf8_view = Utf8View { string };
|
||||
for (u32 code_point : utf8_view) {
|
||||
code_point = to_ascii_uppercase(code_point);
|
||||
TRY(string_builder.try_append(code_point));
|
||||
}
|
||||
return string_builder.to_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue