mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 07:36:50 +00: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:
committed by
Andrew Kaster
parent
1aedb0ae5a
commit
82c827fc56
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user