From 65cf562a71f24f9475c82981c77f5424e7bf845c Mon Sep 17 00:00:00 2001 From: martinfalisse Date: Wed, 1 Feb 2023 18:47:56 +0100 Subject: [PATCH] Ladybird: Add `ak_string_from_qstring` function This will be used later when doing the conversion from the QString in QSettings for the homepage URL. --- Ladybird/Utilities.cpp | 5 +++++ Ladybird/Utilities.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/Ladybird/Utilities.cpp b/Ladybird/Utilities.cpp index ec2ba8ba2b8..7c823644c76 100644 --- a/Ladybird/Utilities.cpp +++ b/Ladybird/Utilities.cpp @@ -19,6 +19,11 @@ AK::DeprecatedString ak_deprecated_string_from_qstring(QString const& qstring) return AK::DeprecatedString(qstring.toUtf8().data()); } +ErrorOr ak_string_from_qstring(QString const& qstring) +{ + return String::from_utf8(StringView(qstring.toUtf8().data(), qstring.size())); +} + QString qstring_from_ak_deprecated_string(AK::DeprecatedString const& ak_deprecated_string) { return QString::fromUtf8(ak_deprecated_string.characters(), ak_deprecated_string.length()); diff --git a/Ladybird/Utilities.h b/Ladybird/Utilities.h index 2638fc67331..5084476d5ff 100644 --- a/Ladybird/Utilities.h +++ b/Ladybird/Utilities.h @@ -7,9 +7,11 @@ #pragma once #include +#include #include AK::DeprecatedString ak_deprecated_string_from_qstring(QString const&); +ErrorOr ak_string_from_qstring(QString const&); QString qstring_from_ak_deprecated_string(AK::DeprecatedString const&); void platform_init();