1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 01:54:57 +00:00
serenity/Ladybird/Qt/StringUtils.cpp
Andrew Kaster c75bd4ed15 Ladybird/Qt: Rename new_tab to new_tab_from_url and make it take AK::URL
Instead of having QString be the API for these load() calls, just pipe
AK::URL throughout the UI.
2024-02-03 20:51:37 -05:00

33 lines
827 B
C++

/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "StringUtils.h"
AK::ByteString ak_byte_string_from_qstring(QString const& qstring)
{
return AK::ByteString(qstring.toUtf8().data());
}
String ak_string_from_qstring(QString const& qstring)
{
auto utf8_data = qstring.toUtf8();
return MUST(String::from_utf8(StringView(utf8_data.data(), utf8_data.size())));
}
QString qstring_from_ak_string(StringView ak_string)
{
return QString::fromUtf8(ak_string.characters_without_null_termination(), static_cast<qsizetype>(ak_string.length()));
}
AK::URL ak_url_from_qstring(QString const& qstring)
{
return AK::URL(qstring.toUtf8().data());
}
AK::URL ak_url_from_qurl(QUrl const& qurl)
{
return AK::URL(qurl.toString().toUtf8().data());
}