diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2020-11-15 18:49:29 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2020-12-09 12:00:03 -0800 |
commit | b359fd6c2a0b64ce3f4a942ec2ce9afd931b0933 (patch) | |
tree | 21c3902f77f16280184f49e93dbb38e30ca4cf10 /src/corelib/text/qstringconverter.cpp | |
parent | af520c8ef32aef67b4e06c60c4fdb49338afeb38 (diff) |
QStringConverter: add comments marking the BOM checks and emissions
Because obscure cultural references never go out of style.
https://twitter.com/steveklabnik/status/1327745325688365056?s=21
Change-Id: Idbe0d2174d4943d1865cfffd1647dd3a18af1801
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/text/qstringconverter.cpp')
-rw-r--r-- | src/corelib/text/qstringconverter.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp index a0015c2c83..524bb4cc03 100644 --- a/src/corelib/text/qstringconverter.cpp +++ b/src/corelib/text/qstringconverter.cpp @@ -912,6 +912,7 @@ char *QUtf16::convertFromUnicode(char *out, QStringView in, QStringConverter::St endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BigEndianness : LittleEndianness; if (writeBom) { + // set them up the BOM QChar bom(QChar::ByteOrderMark); if (endian == BigEndianness) qToBigEndian(bom.unicode(), out); @@ -974,6 +975,7 @@ QChar *QUtf16::convertToUnicode(QChar *out, QByteArrayView in, QStringConverter: state->internalState |= HeaderDone; QChar ch(buf, *chars++); if (endian == DetectEndianness) { + // someone set us up the BOM if (ch == QChar::ByteOrderSwapped) { endian = BigEndianness; } else if (ch == QChar::ByteOrderMark) { @@ -1043,6 +1045,7 @@ char *QUtf32::convertFromUnicode(char *out, QStringView in, QStringConverter::St endian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? BigEndianness : LittleEndianness; if (writeBom) { + // set them up the BOM if (endian == BigEndianness) { out[0] = 0; out[1] = 0; @@ -1151,6 +1154,7 @@ QChar *QUtf32::convertToUnicode(QChar *out, QByteArrayView in, QStringConverter: while (num < 4) tuple[num++] = *chars++; if (endian == DetectEndianness) { + // someone set us up the BOM? if (tuple[0] == 0xff && tuple[1] == 0xfe && tuple[2] == 0 && tuple[3] == 0) { endian = LittleEndianness; } else if (tuple[0] == 0 && tuple[1] == 0 && tuple[2] == 0xfe && tuple[3] == 0xff) { @@ -1757,6 +1761,7 @@ std::optional<QStringConverter::Encoding> QStringConverter::encodingForName(cons */ std::optional<QStringConverter::Encoding> QStringConverter::encodingForData(QByteArrayView data, char16_t expectedFirstCharacter) { + // someone set us up the BOM? qsizetype arraySize = data.size(); if (arraySize > 3) { uint uc = qFromUnaligned<uint>(data.data()); |