diff --git a/AK/String.cpp b/AK/String.cpp index 15a5dafc092..333a92d0679 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -491,6 +491,16 @@ bool String::contains(char needle, CaseSensitivity case_sensitivity) const return contains(StringView { &needle, 1 }, case_sensitivity); } +bool String::starts_with_bytes(StringView bytes) const +{ + return bytes_as_string_view().starts_with(bytes); +} + +bool String::starts_with(u32 code_point) const +{ + return bytes_as_string_view().starts_with(code_point); +} + bool String::is_short_string() const { return has_short_string_bit(reinterpret_cast(m_data)); diff --git a/AK/String.h b/AK/String.h index c3b59d2f3b9..9b46a08d626 100644 --- a/AK/String.h +++ b/AK/String.h @@ -109,6 +109,9 @@ public: // Compare this String against another string with caseless matching. Using this method requires linking LibUnicode into your application. ErrorOr equals_ignoring_case(String const&) const; + bool starts_with(u32 code_point) const; + bool starts_with_bytes(StringView) 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; ErrorOr substring_from_byte_offset(size_t start) const;