summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstringview.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-04-05 00:07:09 +0200
committerMarc Mutz <marc.mutz@kdab.com>2017-04-07 08:54:16 +0000
commit5dc1e08c8c602738f6a827cea0de44683c7bbd0b (patch)
treec413e9dfbeb5db2fc5e9377c9fdac97bf60f457a /src/corelib/tools/qstringview.cpp
parent86005ea2570fcce81db8e3f4988f5541b4624de8 (diff)
Add qConvertTo{Utf8,Latin1,Local8Bit,Ucs4}() and corresponding QStringView methods
Like the qt_compare_strings()/qCompareStrings() split, distinguish between the internal and exported functions. Because of the circular dependency between qstring.h and qvector.h, the inline toUcs4() function has to be in qvector.h. At some point, we need to refactor the headers so qvector.h is lower in the dependency chain than qstring.h. It's not the first time this bites. Change-Id: Ief9f3bd92c83cdd1f31c51c700f42e146916eefd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qstringview.cpp')
-rw-r--r--src/corelib/tools/qstringview.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/corelib/tools/qstringview.cpp b/src/corelib/tools/qstringview.cpp
index adffe1800c..65f76965f6 100644
--- a/src/corelib/tools/qstringview.cpp
+++ b/src/corelib/tools/qstringview.cpp
@@ -616,4 +616,55 @@ QT_BEGIN_NAMESPACE
\sa mid(), left()
*/
+/*!
+ \fn QByteArray QStringView::toLatin1() const
+
+ Returns a Latin-1 representation of the string as a QByteArray.
+
+ The behavior is undefined if the string contains non-Latin1 characters.
+
+ \sa toUtf8(), toLocal8Bit(), QTextCodec, qConvertToLatin1()
+*/
+
+/*!
+ \fn QByteArray QStringView::toLocal8Bit() const
+
+ Returns a local 8-bit representation of the string as a QByteArray.
+
+ QTextCodec::codecForLocale() is used to perform the conversion from
+ Unicode. If the locale's encoding could not be determined, this function
+ does the same as toLatin1().
+
+ The behavior is undefined if the string contains characters not
+ supported by the locale's 8-bit encoding.
+
+ \sa toLatin1(), toUtf8(), QTextCodec, qConvertToLocal8Bit()
+*/
+
+/*!
+ \fn QByteArray QStringView::toUtf8() const
+
+ Returns a UTF-8 representation of the string as a QByteArray.
+
+ UTF-8 is a Unicode codec and can represent all characters in a Unicode
+ string like QString.
+
+ \sa toLatin1(), toLocal8Bit(), QTextCodec, qConvertToUtf8()
+*/
+
+/*!
+ \fn QVector<uint> QStringView::toUcs4() const
+
+ Returns a UCS-4/UTF-32 representation of the string as a QVector<uint>.
+
+ UCS-4 is a Unicode codec and therefore it is lossless. All characters from
+ this string will be encoded in UCS-4. Any invalid sequence of code units in
+ this string is replaced by the Unicode replacement character
+ (QChar::ReplacementCharacter, which corresponds to \c{U+FFFD}).
+
+ The returned vector is not 0-terminated.
+
+ \sa toUtf8(), toLatin1(), toLocal8Bit(), QTextCodec
+*/
+
QT_END_NAMESPACE