2023-08-05 16:42:26 +00:00
|
|
|
/*
|
2024-10-04 11:19:50 +00:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2023-08-05 16:42:26 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2024-11-09 17:50:33 +00:00
|
|
|
#include <UI/Qt/StringUtils.h>
|
2023-08-05 16:42:26 +00:00
|
|
|
|
2023-12-16 14:19:34 +00:00
|
|
|
AK::ByteString ak_byte_string_from_qstring(QString const& qstring)
|
2023-08-05 16:42:26 +00:00
|
|
|
{
|
2024-02-14 11:10:58 +00:00
|
|
|
auto utf8_data = qstring.toUtf8();
|
|
|
|
return AK::ByteString(utf8_data.data(), utf8_data.size());
|
2023-08-05 16:42:26 +00:00
|
|
|
}
|
|
|
|
|
2023-12-04 15:08:16 +00:00
|
|
|
String ak_string_from_qstring(QString const& qstring)
|
2023-08-05 16:42:26 +00:00
|
|
|
{
|
2023-12-04 15:12:06 +00:00
|
|
|
auto utf8_data = qstring.toUtf8();
|
2023-12-04 15:08:16 +00:00
|
|
|
return MUST(String::from_utf8(StringView(utf8_data.data(), utf8_data.size())));
|
2023-08-05 16:42:26 +00:00
|
|
|
}
|
|
|
|
|
2023-12-04 14:55:47 +00:00
|
|
|
QString qstring_from_ak_string(StringView ak_string)
|
2023-08-05 16:42:26 +00:00
|
|
|
{
|
2023-12-04 14:55:47 +00:00
|
|
|
return QString::fromUtf8(ak_string.characters_without_null_termination(), static_cast<qsizetype>(ak_string.length()));
|
2023-08-05 16:42:26 +00:00
|
|
|
}
|
2024-01-31 02:15:55 +00:00
|
|
|
|
2024-03-18 03:22:27 +00:00
|
|
|
URL::URL ak_url_from_qstring(QString const& qstring)
|
2024-01-31 02:15:55 +00:00
|
|
|
{
|
2024-02-14 11:10:58 +00:00
|
|
|
auto utf8_data = qstring.toUtf8();
|
2024-03-18 03:22:27 +00:00
|
|
|
return URL::URL(StringView(utf8_data.data(), utf8_data.size()));
|
2024-01-31 02:15:55 +00:00
|
|
|
}
|
|
|
|
|
2024-03-18 03:22:27 +00:00
|
|
|
URL::URL ak_url_from_qurl(QUrl const& qurl)
|
2024-01-31 02:15:55 +00:00
|
|
|
{
|
2024-02-14 11:10:58 +00:00
|
|
|
return ak_url_from_qstring(qurl.toString());
|
2024-01-31 02:15:55 +00:00
|
|
|
}
|