#include <qutfcodec_p.h>
Definition at line 68 of file qutfcodec_p.h.
◆ convertFromUnicode()
Definition at line 64 of file qutfcodec.cpp.
Referenced by QUtf8Codec::convertFromUnicode(), QUtf16Codec::QUtf16Codec(), QUtf32Codec::QUtf32Codec(), QString::toUtf8(), and QStringRef::toUtf8().
66 uchar replacement =
'?';
68 int surrogate_high = -1;
92 if (surrogate_high >= 0) {
98 *cursor = replacement;
106 *cursor = replacement;
117 *cursor++ = (
uchar)u;
120 *cursor++ = 0xc0 | ((
uchar) (u >> 6));
124 *cursor++ = replacement;
131 *cursor++ = 0xf0 | ((
uchar) (u >> 18));
132 *cursor++ = 0x80 | (((
uchar) (u >> 12)) & 0x3f);
134 *cursor++ = 0xe0 | (((
uchar) (u >> 12)) & 0x3f);
136 *cursor++ = 0x80 | (((
uchar) (u >> 6)) & 0x3f);
138 *cursor++ = 0x80 | ((
uchar) (u&0x3f));
148 if (surrogate_high >= 0) {
char * data()
Returns a pointer to the data stored in the byte array.
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QByteArray class provides an array of bytes.
bool isLowSurrogate() const
Returns true if the QChar is the low part of a utf16 surrogate (ie.
bool isHighSurrogate() const
Returns true if the QChar is the high part of a utf16 surrogate (ie.
The QChar class provides a 16-bit Unicode character.
const char * constData() const
Returns a pointer to the data stored in the byte array.
static bool isUnicodeNonCharacter(uint ucs4)
void resize(int size)
Sets the size of the byte array to size bytes.
static uint surrogateToUcs4(ushort high, ushort low)
Converts a UTF16 surrogate pair with the given high and low values to its UCS-4 code point...
static const KeyPair *const end
◆ convertToUnicode()
Definition at line 156 of file qutfcodec.cpp.
Referenced by QUtf8Codec::convertToUnicode(), QString::fromUtf8(), QUtf16Codec::QUtf16Codec(), and QUtf32Codec::QUtf32Codec().
158 bool headerdone =
false;
175 if (!headerdone && len > 3
176 && (
uchar)chars[0] == 0xef && (
uchar)chars[1] == 0xbb && (
uchar)chars[2] == 0xbf) {
188 for (
int i = 0; i < len; ++i) {
191 if ((ch&0xc0) == 0x80) {
192 uc = (uc << 6) | (ch & 0x3f);
197 if (!headerdone && uc == 0xfeff) {
201 Q_ASSERT((qch - (
ushort*)result.unicode()) + 2 < result.length());
204 }
else if ((uc < min_uc) || (uc >= 0xd800 && uc <= 0xdfff) || nonCharacter || uc >= 0x110000) {
206 *qch++ = replacement;
216 *qch++ = replacement;
225 }
else if ((ch & 0xe0) == 0xc0) {
231 }
else if ((ch & 0xf0) == 0xe0) {
236 }
else if ((ch&0xf8) == 0xf0) {
244 *qch++ = replacement;
250 if (!state && need > 0) {
252 for (
int i = error; i < len; ++i) {
253 *qch++ = replacement;
257 result.truncate(qch - (
ushort *)result.unicode());
The QString class provides a Unicode character string.
static ushort highSurrogate(uint ucs4)
Returns the high surrogate value of a ucs4 code point.
static ushort lowSurrogate(uint ucs4)
Returns the low surrogate value of a ucs4 code point.
static bool isUnicodeNonCharacter(uint ucs4)
The documentation for this struct was generated from the following files: