Results 1 to 5 of 5

Thread: How to use Unicode in Qt source code.

  1. #1
    Join Date
    Mar 2010
    Posts
    69
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default How to use Unicode in Qt source code.

    Hi Everyone,
    I want to use Unicode in my source code. I am generating a database randomly and for that I am using the following code;

    Qt Code:
    1. #define COUNT (20)
    2.  
    3. char* ppcFirstNames[COUNT] = {"কফজগ্লস্ক","কফজগ্লস্ক","কফজগ্লস্ক","কফজগ্লস্ক","কফজগ্লস্ক",
    4. "কফজগ্লস্ক","কফজগ্লস্ক","কফজগ্লস্ক","কফজগ্লস্ক","কফজগ্লস্ক",
    5. "কফজগ্লস্ক","কফজগ্লস্ক","কফজগ্লস্ক","কফজগ্লস্ক","কফজগ্লস্ক",
    6. "কফজগ্লস্ক","কফজগ্লস্ক","কফজগ্লস্ক","কফজগ্লস্ক","কফজগ্লস্ক"};
    To copy to clipboard, switch view to plain text mode 

    But when I am trying this it gives me the following warning and it stores some funny characters in my database;

    warning C4566: character represented by universal-character-name '\u09CD' cannot be represented in the current code page (1252)

    Any help will be appreciated.
    Thanks in advance.

    Chandan
    Last edited by wysota; 26th May 2010 at 12:04.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to use Unicode in Qt source code.

    The issue is not related to Qt but rather to the compiler you are using.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2010
    Posts
    69
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to use Unicode in Qt source code.

    If it is not then I am sorry. But I think I am facing this problem in the Qt application and so it is related to Qt for me. If you think it is not then no need to answer. There are other people who can help.

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to use Unicode in Qt source code.

    Source code should only contain characters in the ASCII range 32-126 (sometimes 127 depending on compiler).

    To use Unicode characters such as the ones you are using, you need to decide how to represent them and type them as such. For example, UTF8, UTF16, UCS-2, ...

    So your string could be 0xC2, 0xA2, for a single Unicode character.

    As said, this is not a Qt question (you would have the same problem without Qt), so a better forum would be general programming.

  5. #5
    Join Date
    Nov 2007
    Posts
    89
    Thanked 21 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to use Unicode in Qt source code.

    It seems like that the file is not UTF-8, but 1252. Try opening it with some application like Notepad++ and if so convert it to UTF-8. Then, if you are using QtCreator, change default encoding in the project page.

Similar Threads

  1. Where is the source code?
    By Fletcher in forum Newbie
    Replies: 1
    Last Post: 10th December 2009, 20:45
  2. Replies: 6
    Last Post: 7th August 2009, 17:00
  3. source code
    By Colx007 in forum Newbie
    Replies: 5
    Last Post: 19th December 2007, 09:15
  4. source in unicode 4.0
    By conexion2000 in forum Qt Programming
    Replies: 1
    Last Post: 10th August 2007, 11:28
  5. Qte source code
    By Gaurav vyas in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 1st July 2007, 14:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.