60 return (ucs4 & 0xfffe) == 0xfffe
61 || (ucs4 - 0xfdd0U) < 16;
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) {
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) {
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;
287 data[1] = bom.
cell();
289 data[0] = bom.
cell();
295 for (
int i = 0; i < len; ++i) {
296 *(data++) = uc[i].row();
297 *(data++) = uc[i].cell();
300 for (
int i = 0; i < len; ++i) {
301 *(data++) = uc[i].cell();
302 *(data++) = uc[i].row();
318 bool headerdone =
false;
351 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
405 data[2] = (char)0xfe;
406 data[3] = (char)0xff;
408 data[0] = (char)0xff;
409 data[1] = (char)0xfe;
416 for (
int i = 0; i < len; ++i) {
418 if (uc[i].isHighSurrogate() && i < len - 1)
420 *(data++) = cp >> 24;
421 *(data++) = (cp >> 16) & 0xff;
422 *(data++) = (cp >> 8) & 0xff;
423 *(data++) = cp & 0xff;
426 for (
int i = 0; i < len; ++i) {
428 if (uc[i].isHighSurrogate() && i < len - 1)
430 *(data++) = cp & 0xff;
431 *(data++) = (cp >> 8) & 0xff;
432 *(data++) = (cp >> 16) & 0xff;
433 *(data++) = cp >> 24;
449 bool headerdone =
false;
462 result.
resize((num + len) >> 2 << 1);
465 const char *
end = chars + len;
466 while (chars < end) {
467 tuple[num++] = *chars++;
472 if (tuple[0] == 0xff && tuple[1] == 0xfe && tuple[2] == 0 && tuple[3] == 0 && endian !=
BigEndianness) {
476 }
else if (tuple[0] == 0 && tuple[1] == 0 && tuple[2] == 0xfe && tuple[3] == 0xff && endian !=
LittleEndianness) {
480 }
else if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
492 if (code >= 0x10000) {
514 #ifndef QT_NO_TEXTCODEC 668 #endif //QT_NO_TEXTCODEC Q_CORE_EXPORT QTextStream & bom(QTextStream &s)
static QByteArray convertFromUnicode(const QChar *, int, QTextCodec::ConverterState *, DataEndianness=DetectEndianness)
static QString convertToUnicode(const char *, int, QTextCodec::ConverterState *, DataEndianness=DetectEndianness)
QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const
QTextCodec subclasses must reimplement this function.
#define QT_END_NAMESPACE
This macro expands to.
QList< QByteArray > aliases() const
Subclasses can return a number of aliases for the codec in question.
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...
int mibEnum() const
Subclasses of QTextCodec must reimplement this function.
The QByteArray class provides an array of bytes.
int length() const
Returns the number of characters in this string.
bool isLowSurrogate() const
Returns true if the QChar is the low part of a utf16 surrogate (ie.
QList< QByteArray > aliases() const
Subclasses can return a number of aliases for the codec in question.
int mibEnum() const
Subclasses of QTextCodec must reimplement this function.
quint32 qFromBigEndian< quint32 >(const uchar *src)
int mibEnum() const
Subclasses of QTextCodec must reimplement this function.
The QString class provides a Unicode character string.
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.
static QByteArray convertFromUnicode(const QChar *, int, QTextCodec::ConverterState *)
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.
QByteArray name() const
QTextCodec subclasses must reimplement this function.
QByteArray name() const
QTextCodec subclasses must reimplement this function.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QByteArray name() const
QTextCodec subclasses must reimplement this function.
void truncate(int pos)
Truncates the string at the given position index.
QByteArray name() const
QTextCodec subclasses must reimplement this function.
QList< QByteArray > aliases() const
Subclasses can return a number of aliases for the codec in question.
const QChar * unicode() const
Returns a '\0'-terminated Unicode representation of the string.
static QString convertToUnicode(const char *, int, QTextCodec::ConverterState *)
quint32 qFromLittleEndian< quint32 >(const uchar *src)
static QByteArray convertFromUnicode(const QChar *, int, QTextCodec::ConverterState *, DataEndianness=DetectEndianness)
static const char * data(const QByteArray &arr)
void resize(int size)
Sets the size of the string to size characters.
const char * constData() const
Returns a pointer to the data stored in the byte array.
QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const
QTextCodec subclasses must reimplement this function.
QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const
QTextCodec subclasses must reimplement this function.
QList< QByteArray > aliases() const
Subclasses can return a number of aliases for the codec in question.
static bool isUnicodeNonCharacter(uint ucs4)
void resize(int size)
Sets the size of the byte array to size bytes.
static QString convertToUnicode(const char *, int, QTextCodec::ConverterState *, DataEndianness=DetectEndianness)
if(void) toggleToolbarShown
uchar cell() const
Returns the cell (least significant byte) of the Unicode character.
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...
int mibEnum() const
Subclasses of QTextCodec must reimplement this function.
int mibEnum() const
Subclasses of QTextCodec must reimplement this function.
QList< QByteArray > aliases() const
Subclasses can return a number of aliases for the codec in question.
int mibEnum() const
Subclasses of QTextCodec must reimplement this function.
QString convertToUnicode(const char *, int, ConverterState *) const
QTextCodec subclasses must reimplement this function.
static const KeyPair *const end
uchar row() const
Returns the row (most significant byte) of the Unicode character.
QString convertToUnicode(const char *, int, ConverterState *) const
QTextCodec subclasses must reimplement this function.
QByteArray name() const
QTextCodec subclasses must reimplement this function.
int mibEnum() const
Subclasses of QTextCodec must reimplement this function.
QByteArray name() const
QTextCodec subclasses must reimplement this function.
QByteArray name() const
QTextCodec subclasses must reimplement this function.
QString convertToUnicode(const char *, int, ConverterState *) const
QTextCodec subclasses must reimplement this function.
QList< QByteArray > aliases() const
Subclasses can return a number of aliases for the codec in question.