mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
LibWeb: Add to_ascii_lower_case() from the Infra spec
https://infra.spec.whatwg.org/#ascii-lowercase
This commit is contained in:
parent
2facb0e8ed
commit
2c1e15bd3b
Notes:
sideshowbarker
2024-07-17 03:35:16 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/2c1e15bd3b Pull-request: https://github.com/SerenityOS/serenity/pull/17614 Reviewed-by: https://github.com/linusg ✅
@ -106,4 +106,18 @@ ErrorOr<String> convert_to_scalar_value_string(StringView string)
|
||||
return scalar_value_builder.to_string();
|
||||
}
|
||||
|
||||
// https://infra.spec.whatwg.org/#ascii-lowercase
|
||||
ErrorOr<String> to_ascii_lower_case(StringView string)
|
||||
{
|
||||
// To ASCII lowercase a string, replace all ASCII upper alphas in the string with their
|
||||
// corresponding code point in ASCII lower alpha.
|
||||
StringBuilder string_builder;
|
||||
auto utf8_view = Utf8View { string };
|
||||
for (u32 code_point : utf8_view) {
|
||||
code_point = to_ascii_lowercase(code_point);
|
||||
TRY(string_builder.try_append(code_point));
|
||||
}
|
||||
return string_builder.to_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,5 +17,6 @@ bool is_ascii_case_insensitive_match(StringView a, StringView b);
|
||||
DeprecatedString strip_and_collapse_whitespace(StringView string);
|
||||
bool is_code_unit_prefix(StringView potential_prefix, StringView input);
|
||||
ErrorOr<String> convert_to_scalar_value_string(StringView string);
|
||||
ErrorOr<String> to_ascii_lower_case(StringView string);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user