Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved] How to initialize QString with Unicode Characters?



  • Dear friends,

    I would like to initialize QString with Unicode Characters.

    @QString myStr = QString("\x1000\x1010\x1020\x1030");@

    Like that, but it doesn't work. What is the escape character for unicode?
    \x? \u?
    What I find on Doc is just insertion of QChar(0x1000) into QString char by char.

    Thanks



  • I would try ditching the double backslashes and maybe use a u instead of an x.

    In the back of my mind there is something about being able to use html (တ) notation, but I don't know for sure, and didn't find the docs that would support that.



  • Okay.. from what I see... you don't need double backslashes for this one and try if this works..

    @ QString str = QString::fromUtf8("Test \u20AC"); @

    Gives me a test + euro sign?



  • For me it indeed gives "Test €".


Log in to reply