mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-17 07:50:04 +00:00
AK: Define some UTF-16 helper methods
* contains * escape_html_entities * replace * to_ascii_lowercase * to_ascii_uppercase * to_ascii_titlecase * trim * trim_whitespace
This commit is contained in:
parent
7f069efbc4
commit
6e0290ecaa
Notes:
github-actions[bot]
2025-07-18 16:47:12 +00:00
Author: https://github.com/trflynn89
Commit: 6e0290ecaa
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5388
Reviewed-by: https://github.com/shannonbooth ✅
6 changed files with 345 additions and 1 deletions
|
@ -43,6 +43,41 @@ public:
|
|||
return Utf16String { move(copy) };
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Utf16FlyString to_ascii_lowercase() const
|
||||
{
|
||||
auto view = m_data.utf16_view();
|
||||
|
||||
if (view.has_ascii_storage()) {
|
||||
if (!any_of(view.ascii_span(), is_ascii_upper_alpha))
|
||||
return *this;
|
||||
} else {
|
||||
if (!any_of(view.utf16_span(), is_ascii_upper_alpha))
|
||||
return *this;
|
||||
}
|
||||
|
||||
return view.to_ascii_lowercase();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Utf16FlyString to_ascii_uppercase() const
|
||||
{
|
||||
auto view = m_data.utf16_view();
|
||||
|
||||
if (view.has_ascii_storage()) {
|
||||
if (!any_of(view.ascii_span(), is_ascii_lower_alpha))
|
||||
return *this;
|
||||
} else {
|
||||
if (!any_of(view.utf16_span(), is_ascii_lower_alpha))
|
||||
return *this;
|
||||
}
|
||||
|
||||
return view.to_ascii_uppercase();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Utf16FlyString to_ascii_titlecase() const
|
||||
{
|
||||
return view().to_ascii_titlecase();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Utf16FlyString& operator=(Utf16String const& string)
|
||||
{
|
||||
*this = Utf16FlyString { string };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue