mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-05 23:59:53 +00:00
LibJS+LibUnicode: Port Intl.ListFormat to UTF-16 strings
This commit is contained in:
parent
7d80aabbdb
commit
db2148b44a
Notes:
github-actions[bot]
2025-07-24 08:41:31 +00:00
Author: https://github.com/trflynn89
Commit: db2148b44a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5581
7 changed files with 39 additions and 33 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2024-2025, Tim Flynn <trflynn89@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -82,7 +82,7 @@ public:
|
|||
|
||||
virtual ~ListFormatImpl() override = default;
|
||||
|
||||
virtual String format(ReadonlySpan<String> list) const override
|
||||
virtual Utf16String format(ReadonlySpan<Utf16String> list) const override
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
|
@ -94,10 +94,10 @@ public:
|
|||
if (icu_failure(status))
|
||||
return {};
|
||||
|
||||
return icu_string_to_string(formatted_string);
|
||||
return icu_string_to_utf16_string(formatted_string);
|
||||
}
|
||||
|
||||
virtual Vector<Partition> format_to_parts(ReadonlySpan<String> list) const override
|
||||
virtual Vector<Partition> format_to_parts(ReadonlySpan<Utf16String> list) const override
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
|
@ -118,14 +118,14 @@ public:
|
|||
auto type = icu_list_format_field_to_string(position.getField());
|
||||
auto part = formatted_string.tempSubStringBetween(position.getStart(), position.getLimit());
|
||||
|
||||
result.empend(type, icu_string_to_string(part));
|
||||
result.empend(type, icu_string_to_utf16_string(part));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
Optional<icu::FormattedList> format_list_impl(ReadonlySpan<String> list) const
|
||||
Optional<icu::FormattedList> format_list_impl(ReadonlySpan<Utf16String> list) const
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue