Qt World Summit: Submit your Presentation

Unicode: setCodec("UTF-32le") not pairs surrogates

  • Unicode map 20000-20FFF

    #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);
        QFile file("h:\\res\\eutf32le.txt");
        file.open(QIODevice::WriteOnly | QIODevice::Text);
        QTextStream out(&file);
        out << extstr;

    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.

Log in to reply