Initialize QChar with unicode japanese character

  • Hi all

    I knwo the question would be really stupid but I still didn't find a way to make that. I want to initialize a QChar with a unicode japanese character by source but I didn't get the extepctyed result.

    I tried:

    QChar myChar('あ');

    In this case the QChar object contain a unicode character but is not the same I used for initialize. Using the other test:

    QChar myChar(L'あ');

    doesn't work, in this case the character seem inside the ASCII range not unicode. The cpp source file containing this code is saved in unicode without BOM format. Currently the only working way I found is the following:

    QChar myChar(QString("あ").at(0));

    but is really orrible. Someone know the right way to make such initialization?
    Thank you

  • Moderators

    For UTF-8 you can do this:


    or use it like this way


    Should work (Unicode values in the examples may be incorrect)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.