PDA

View Full Version : I have a problem ,how to get chinese unicode ?



tsuibin
8th April 2009, 08:27
i use
QChar('影').unicode();
compiler

Warning: multi-byte character constant :eek::confused::confused:

how to get chinese's unicode ?

wysota
8th April 2009, 08:59
Either use utf-8 or check the unicode value of the glyph you want to encode and provide it in decimal or hexadecimal form - there is a QChar constructor variant taking two uints.

tsuibin
8th April 2009, 09:23
Either use utf-8 or check the unicode value of the glyph you want to encode and provide it in decimal or hexadecimal form - there is a QChar constructor variant taking two uints.

i used

QTextCodec::setCodecForTr(QTextCodec::codecForName ("UTF-8"));

but , the problem was unsolv

wysota
8th April 2009, 09:48
Setting a codec won't help. You are using multibyte characters in your source code and the compiler doesn't like it. You should only use singlebyte characters in sourcecodes regardless of the language you use.

talk2amulya
8th April 2009, 09:54
since QChar is multi-byte, shouldnt it be ok to give it a multi-byte unicode value? and even if compiler gives a warning..shouldnt the guy be able to get the chinese unicode?

wysota
8th April 2009, 10:26
It's not about QChar. It's about the CPP preprocessor or C++ compiler that issues the warning. QChar can accept unicode characters but you have to give them as two separate 8 bit parts. This is incorrect according to C++ standard: 'aa' (two characters in single quotes) and that's exactly what he is passing.