1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:44:58 +00:00

AK: Bring some missing DeprecatedString API over to String

Specifically, case sensitivity parameters for starts/ends with,
and the equals_ignoring_ascii_case() helper.
This commit is contained in:
Andreas Kling 2023-11-04 10:07:01 +01:00
parent f052823f5f
commit 0902f552a3
2 changed files with 13 additions and 6 deletions

View file

@ -513,9 +513,9 @@ bool String::starts_with(u32 code_point) const
return *code_points().begin() == code_point;
}
bool String::starts_with_bytes(StringView bytes) const
bool String::starts_with_bytes(StringView bytes, CaseSensitivity case_sensitivity) const
{
return bytes_as_string_view().starts_with(bytes);
return bytes_as_string_view().starts_with(bytes, case_sensitivity);
}
bool String::ends_with(u32 code_point) const
@ -530,9 +530,9 @@ bool String::ends_with(u32 code_point) const
return last_code_point == code_point;
}
bool String::ends_with_bytes(StringView bytes) const
bool String::ends_with_bytes(StringView bytes, CaseSensitivity case_sensitivity) const
{
return bytes_as_string_view().ends_with(bytes);
return bytes_as_string_view().ends_with(bytes, case_sensitivity);
}
bool String::is_short_string() const
@ -626,4 +626,9 @@ ErrorOr<String> String::from_deprecated_string(DeprecatedString const& deprecate
return String::from_utf8(deprecated_string.view());
}
bool String::equals_ignoring_ascii_case(StringView other) const
{
return StringUtils::equals_ignoring_ascii_case(bytes_as_string_view(), other);
}
}