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. Initialize QChar with unicode japanese character
Forum Updated to NodeBB v4.3 + New Features

Initialize QChar with unicode japanese character

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.0k 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.
  • deleted57D Offline
    deleted57D Offline
    deleted57
    wrote on last edited by
    #1

    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

    raven-worxR 1 Reply Last reply
    0
    • deleted57D deleted57

      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

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @Suppaman
      For UTF-8 you can do this:

      QString::fromUtf8("\u00F5");
      

      or use it like this way

      QChar(0x00F5);
      

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

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      3

      • Login

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