PDA

View Full Version : How to use Unicode in Qt source code.



chandan
26th May 2010, 11:46
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;



#define COUNT (20)

char* ppcFirstNames[COUNT] = {"কফজগ্লস্ ক","কফজগ্লস্ ক","কফজগ্লস্ ক","কফজগ্লস্ ক","কফজগ্লস্ ক",
"কফজগ্লস্ ক","কফজগ্লস্ ক","কফজগ্লস্ ক","কফজগ্লস্ ক","কফজগ্লস্ ক",
"কফজগ্লস্ ক","কফজগ্লস্ ক","কফজগ্লস্ ক","কফজগ্লস্ ক","কফজগ্লস্ ক",
"কফজগ্লস্ ক","কফজগ্লস্ ক","কফজগ্লস্ ক","কফজগ্লস্ ক","কফজগ্লস্ ক"};


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

wysota
26th May 2010, 12:05
The issue is not related to Qt but rather to the compiler you are using.

chandan
26th May 2010, 12:09
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.

squidge
26th May 2010, 13:03
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.

bender86
26th May 2010, 14:07
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.