mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-24 00:49:46 +00:00
AK: Implement a method to split a UTF-16 string
This commit is contained in:
parent
48a3b2c28e
commit
baddac5155
Notes:
github-actions[bot]
2025-07-28 10:27:13 +00:00
Author: https://github.com/trflynn89
Commit: baddac5155
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5610
4 changed files with 115 additions and 0 deletions
|
|
@ -254,6 +254,24 @@ Utf16View Utf16View::unicode_substring_view(size_t code_point_offset, size_t cod
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
Vector<Utf16View> Utf16View::split_view(char16_t separator, SplitBehavior split_behavior) const
|
||||
{
|
||||
Utf16View seperator_view { &separator, 1 };
|
||||
return split_view(seperator_view, split_behavior);
|
||||
}
|
||||
|
||||
Vector<Utf16View> Utf16View::split_view(Utf16View const& separator, SplitBehavior split_behavior) const
|
||||
{
|
||||
Vector<Utf16View> parts;
|
||||
|
||||
for_each_split_view(separator, split_behavior, [&](auto const& part) {
|
||||
parts.append(part);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
||||
size_t Utf16View::calculate_length_in_code_points() const
|
||||
{
|
||||
ASSERT(!has_ascii_storage());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue