Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
src_corelib_text_qstringconverter.cpp
Go to the documentation of this file.
1
// Copyright (C) 2020 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
5
QByteArray
encodedString
=
"..."
;
6
auto
toUtf16
=
QStringDecoder
(
QStringDecoder::Utf8
);
7
QString
string
=
toUtf16
(
encodedString
);
9
10
12
QString
string
=
"..."
;
13
auto
fromUtf16
=
QStringEncoder
(
QStringEncoder::Utf8
);
14
QByteArray
encodedString
=
fromUtf16
(
string
);
16
17
19
auto
toUtf16
=
QStringDecoder
(
QStringDecoder::Utf8
);
20
21
QString
string
;
22
while
(new_data_available()) {
23
QByteArray
chunk = get_new_data();
24
string
+=
toUtf16
(chunk);
25
}
27
29
auto
fromUtf16
=
QStringEncoder
(
QStringEncoder::Utf8
);
30
31
QByteArray
encoded
;
32
while
(new_data_available()) {
33
QString
chunk = get_new_data();
34
encoded
+=
fromUtf16
(chunk);
35
}
37
38
{
40
QByteArray
encodedString
=
"..."
;
41
auto
toUtf16
=
QStringDecoder
(
QStringDecoder::Utf8
);
42
auto
data
=
toUtf16
(
encodedString
);
// data's type is QStringDecoder::EncodedData<const QByteArray &>
43
QString
string
=
toUtf16
(
encodedString
);
// Implicit conversion to QString
44
45
// Here you have to cast "data" to QString
46
auto
func
= [&]() {
return
!
toUtf16
.hasError() ?
QString
(
data
) : u
"foo"
_s; }
48
}
49
50
{
52
QString
string
=
"..."
;
53
auto
fromUtf16
=
QStringEncoder
(
QStringEncoder::Utf8
);
54
auto
data
=
fromUtf16
(
string
);
// data's type is QStringEncoder::DecodedData<const QString &>
55
QByteArray
encodedString
=
fromUtf16
(
string
);
// Implicit conversion to QByteArray
56
57
// Here you have to cast "data" to QByteArray
58
auto
func
= [&]() {
return
!
fromUtf16
.hasError() ?
QByteArray
(
data
) :
"foo"
_ba; }
60
}
QByteArray
\inmodule QtCore
Definition
qbytearray.h:57
QStringConverter::Utf8
@ Utf8
Definition
qstringconverter_base.h:91
QStringDecoder
\inmodule QtCore
Definition
qstringconverter.h:86
QStringEncoder
\inmodule QtCore
Definition
qstringconverter.h:21
QString
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition
qstring.h:129
QByteArray
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
data
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
Definition
qopengles2ext.h:206
func
GLenum func
Definition
qopenglext.h:663
toUtf16
auto toUtf16
[1]
Definition
src_corelib_text_qstringconverter.cpp:6
encodedString
QByteArray encodedString
[0]
Definition
src_corelib_text_qstringconverter.cpp:5
fromUtf16
auto fromUtf16
[2]
Definition
src_corelib_text_qstringconverter.cpp:13
encoded
QByteArray encoded
Definition
src_corelib_text_qstringconverter.cpp:31
string
QString string
[0]
Definition
src_corelib_text_qstringconverter.cpp:7
qtbase
src
corelib
doc
snippets
code
src_corelib_text_qstringconverter.cpp
Generated by
1.10.0