Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] How to initialize QString with Unicode Characters?
Forum Update on Monday, May 27th 2025

[Solved] How to initialize QString with Unicode Characters?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 23.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zither
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      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.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jim_kaiser
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on last edited by
          #4

          For me it indeed gives "Test €".

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved