Unsolved Unicode: setCodec("UTF-32le") not pairs surrogates
-
#include <QFile> #include <QTextStream> #include <random> using namespace std; int main(int argc, char *argv[]) { mt19937 gen(0); unsigned int ui[1000]; uniform_int_distribution<unsigned int> dis(0x20000, 0x20fff); for (int i=0; i<1000; i++) ui[i] = dis(gen); QString extstr = QString::fromUcs4(ui,1000); printf("%d\n",extstr.length()); QFile file("h:\\res\\eutf32le.txt"); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); out.setCodec("UTF-32le"); out.setGenerateByteOrderMark(false); out << extstr; file.close(); }
File size = 8000 bytes instead 4000 like ui table.
For utf16->utf8 is OK. -
I check this file and from half is junk, first half seems to be good.