mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:47:34 +00: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
2 changed files with 15 additions and 0 deletions
|
@ -106,4 +106,18 @@ ErrorOr<String> convert_to_scalar_value_string(StringView string)
|
||||||
return scalar_value_builder.to_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);
|
DeprecatedString strip_and_collapse_whitespace(StringView string);
|
||||||
bool is_code_unit_prefix(StringView potential_prefix, StringView input);
|
bool is_code_unit_prefix(StringView potential_prefix, StringView input);
|
||||||
ErrorOr<String> convert_to_scalar_value_string(StringView string);
|
ErrorOr<String> convert_to_scalar_value_string(StringView string);
|
||||||
|
ErrorOr<String> to_ascii_lower_case(StringView string);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue