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. [RESOLVED] Problem of string conversion
Forum Updated to NodeBB v4.3 + New Features

[RESOLVED] Problem of string conversion

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 911 Views 1 Watching
  • 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.
  • A Offline
    A Offline
    Alain38
    wrote on last edited by
    #1

    Hi,
    I have a software that exchanges data with a web server. One request I send to the server is to obtain the name of an user. Unfortunately, I have a case with a (french) name that is "Jérémie". THen, the answer I receive is "J\u00e9r\u00e9mie". So it is a mix between ASCII characters and a code (in ASCII) indicating an Unicode part.

    SO, my question is "how to convert this ASCII string in the QString "Jérémie"?"

    Thanks for your help.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      There's nothing ready-made for that in Qt. You can find all "\uXXXX" strings (either with QString methods or QRegularExpression), convert the XXXX to a number with QString::toInt() and replace the whole thing with QChar(theNumber).

      The easier way (if you control the server) would be to modify your service to return a utf encoded characters and not the string notation of them.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Alain38
        wrote on last edited by
        #3

        Thanks for the answer. I will implement the manual solution.

        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