1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

AK: Make String::{starts,ends}_with(code_point) handle non-ASCII

We currently pass the code point to StringView::{starts,ends}_with,
which actually accepts a single char, thus cannot handle non-ASCII
code points.
This commit is contained in:
Timothy Flynn 2023-03-08 08:56:02 -05:00 committed by Linus Groh
parent f61e65a609
commit f882581e91
3 changed files with 98 additions and 6 deletions

View file

@ -111,11 +111,11 @@ public:
// Compare this String against another string with caseless matching. Using this method requires linking LibUnicode into your application.
ErrorOr<bool> equals_ignoring_case(String const&) const;
bool starts_with(u32 code_point) const;
bool starts_with_bytes(StringView) const;
[[nodiscard]] bool starts_with(u32 code_point) const;
[[nodiscard]] bool starts_with_bytes(StringView) const;
bool ends_with(u32 code_point) const;
bool ends_with_bytes(StringView) const;
[[nodiscard]] bool ends_with(u32 code_point) const;
[[nodiscard]] bool ends_with_bytes(StringView) const;
// Creates a substring with a deep copy of the specified data window.
ErrorOr<String> substring_from_byte_offset(size_t start, size_t byte_count) const;