qt - Parsing QChar from QString as opposed to direct assignment -
why results of inconsistent? encoding on right displayed in debugger. problem right c1 != c2.
qchar c1 = 'ç'; //==> 50087 qstring str = "ç"; qchar c2 = str.at(0); //==> 231 qchar c3 = qstring(c1).at(0); //==> 50087
qt may misinterpreting character processing signed short , applying sign extension it, produces incorrect 50087 value. if explicitly cast character unsigned character - (uchar)'ç'
- should consistent results.
the following code should work you:
qchar c1 = (uchar)'ç'; //==> 231 qstring str = "ç"; qchar c2 = str.at(0); //==> 231 qchar c3 = qstring(c1).at(0); //==> 231
however, since character-set you're using in extended ascii range, suggest use either wide-character or utf8 encoding source strings , characters avoid possible ambiguity when comes extended ascii range. characters in extended ascii range interpreted according code pages, can result in "character set confusion".
Comments
Post a Comment