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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -