diff --git a/AK/String.cpp b/AK/String.cpp index 89017693a33..96ccb18544a 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -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::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); +} + } diff --git a/AK/String.h b/AK/String.h index 475f62111ec..ab7ae9a2e8f 100644 --- a/AK/String.h +++ b/AK/String.h @@ -101,11 +101,13 @@ public: // Compare this String against another string with caseless matching. Using this method requires linking LibUnicode into your application. [[nodiscard]] bool equals_ignoring_case(String const&) const; + [[nodiscard]] bool equals_ignoring_ascii_case(StringView) const; + [[nodiscard]] bool starts_with(u32 code_point) const; - [[nodiscard]] bool starts_with_bytes(StringView) const; + [[nodiscard]] bool starts_with_bytes(StringView, CaseSensitivity = CaseSensitivity::CaseSensitive) const; [[nodiscard]] bool ends_with(u32 code_point) const; - [[nodiscard]] bool ends_with_bytes(StringView) const; + [[nodiscard]] bool ends_with_bytes(StringView, CaseSensitivity = CaseSensitivity::CaseSensitive) const; // Creates a substring with a deep copy of the specified data window. ErrorOr substring_from_byte_offset(size_t start, size_t byte_count) const;