23 #include "utf8splitter.h"
25 #include <QDataStream>
27 QList<QByteArray> Utf8Splitter::split(
const QByteArray &in,
int maxChunkLength)
29 QList<QByteArray> result;
30 QDataStream stream(in);
31 QByteArray largerChunk;
32 while (!stream.atEnd())
37 chunk.append(curByte);
38 if ((curByte & 0x80) != 0)
40 quint8 leading = curByte & 0xfc;
42 while ((leading & 0x80) != 0)
44 leading = leading << 1;
49 for (; numBytes > 1; --numBytes)
53 chunk.append(subByte);
56 if (largerChunk.size() + chunk.size() > maxChunkLength)
58 result << largerChunk;
61 largerChunk.append(chunk);
63 if (!largerChunk.isEmpty())
65 result << largerChunk;