mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
Ladybird/Qt: Support non-ASCII when converting a QString to a String
QString is UTF-16, thus QString::size returns the number of UTF-16 code
units. Thus, we would fail to perform, for example:
ak_string_from_qstring(QString("😀"));
Which is 2 UTF-16 code units, but 4 UTF-8 code units.
This commit is contained in:
parent
1aedb0ae5a
commit
82c827fc56
Notes:
sideshowbarker
2024-07-17 01:10:58 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/82c827fc56 Pull-request: https://github.com/SerenityOS/serenity/pull/22161 Reviewed-by: https://github.com/ADKaster ✅
@ -13,7 +13,8 @@ AK::DeprecatedString ak_deprecated_string_from_qstring(QString const& qstring)
|
||||
|
||||
ErrorOr<String> ak_string_from_qstring(QString const& qstring)
|
||||
{
|
||||
return String::from_utf8(StringView(qstring.toUtf8().data(), qstring.size()));
|
||||
auto utf8_data = qstring.toUtf8();
|
||||
return String::from_utf8(StringView(utf8_data.data(), utf8_data.size()));
|
||||
}
|
||||
|
||||
QString qstring_from_ak_string(StringView ak_string)
|
||||
|
Loading…
Reference in New Issue
Block a user