summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-01-10 20:53:36 +0200
committerAhmad Samir <a.samirh78@gmail.com>2023-01-12 05:05:02 +0200
commitf090a4785b99573dd5a506fec655df1abe347e7c (patch)
tree9ca8e70cb8b917a33dae036c3c047aa03832fe63
parent92a7c360208c6ab7504e8ff9e091fede73839fb1 (diff)
QStringConverter: use qt_to_latin1() helper from qstring.cpp
This changes the newly-added QLatin1::convertFromUnicode() overload. Change-Id: Ie465f052e711d72e51217b74b5b51a89c5d8b9e7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/text/qstring.cpp6
-rw-r--r--src/corelib/text/qstringconverter_p.h8
2 files changed, 9 insertions, 5 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 5de3043c69..9259d485c1 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -5389,6 +5389,12 @@ char16_t *QLatin1::convertToUnicode(char16_t *out, QLatin1StringView in) noexcep
return std::next(out, len);
}
+char *QLatin1::convertFromUnicode(char *out, QStringView in) noexcept
+{
+ const qsizetype len = in.size();
+ qt_to_latin1(reinterpret_cast<uchar *>(out), in.utf16(), len);
+ return out + len;
+}
/*!
\fn QByteArray QString::toLatin1() const
diff --git a/src/corelib/text/qstringconverter_p.h b/src/corelib/text/qstringconverter_p.h
index ce6254de0c..edbe1b5484 100644
--- a/src/corelib/text/qstringconverter_p.h
+++ b/src/corelib/text/qstringconverter_p.h
@@ -50,11 +50,9 @@ struct QLatin1
}
static char *convertFromUnicode(char *out, QStringView in, QStringConverter::State *state) noexcept;
- static char *convertFromUnicode(char *out, QStringView in) noexcept
- {
- QStringConverter::State state{QStringConverter::Flag::Stateless};
- return convertFromUnicode(out, in, &state);
- }
+
+ // Defined in qstring.cpp
+ static char *convertFromUnicode(char *out, QStringView in) noexcept;
};
struct QUtf8BaseTraits