summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-03-13 17:30:31 -0400
committerLinus Groh <mail@linusgroh.de>2023-03-13 22:05:22 +0000
commitb4d3fea0024001f899ace5e6f377d7232df21656 (patch)
tree59c2762957d0d2afc4c575a54cc6cf92dcb557b5
parentfc15968418352c877c2b0827fe1b1b1ab17bdd6d (diff)
downloadserenity-b4d3fea0024001f899ace5e6f377d7232df21656.zip
Ladybird: Add a utility to create a QString from an AK::String
-rw-r--r--Ladybird/Utilities.cpp6
-rw-r--r--Ladybird/Utilities.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/Ladybird/Utilities.cpp b/Ladybird/Utilities.cpp
index 12a534a1a6..4f0fa2de5a 100644
--- a/Ladybird/Utilities.cpp
+++ b/Ladybird/Utilities.cpp
@@ -29,6 +29,12 @@ QString qstring_from_ak_deprecated_string(AK::DeprecatedString const& ak_depreca
return QString::fromUtf8(ak_deprecated_string.characters(), ak_deprecated_string.length());
}
+QString qstring_from_ak_string(String const& ak_string)
+{
+ auto view = ak_string.bytes_as_string_view();
+ return QString::fromUtf8(view.characters_without_null_termination(), view.length());
+}
+
void platform_init()
{
#ifdef AK_OS_ANDROID
diff --git a/Ladybird/Utilities.h b/Ladybird/Utilities.h
index 5084476d5f..a573651523 100644
--- a/Ladybird/Utilities.h
+++ b/Ladybird/Utilities.h
@@ -13,6 +13,7 @@
AK::DeprecatedString ak_deprecated_string_from_qstring(QString const&);
ErrorOr<String> ak_string_from_qstring(QString const&);
QString qstring_from_ak_deprecated_string(AK::DeprecatedString const&);
+QString qstring_from_ak_string(String const&);
void platform_init();
extern DeprecatedString s_serenity_resource_root;