Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify a unicode character using QString?

How can I specify a unicode character by code (such as "4FF0") using QString? I tried QString s("\u4FF0"); but it only outputs a question mark. Any idea how to do this?

Edit:

It works that way, but is there a more direct way?

std::wstring str = L"\u4FF07"; QString s = QString::fromStdWString(str)); 
like image 433
laurent Avatar asked Sep 28 '11 17:09

laurent


People also ask

How do I type a specific Unicode character?

Inserting Unicode characters To insert a Unicode character, type the character code, press ALT, and then press X. For example, to type a dollar symbol ($), type 0024, press ALT, and then press X. For more Unicode character codes, see Unicode character code charts by script.

How do I create a Unicode character in latex?

You can enter Unicode code-point values (the number associated with a character) using carets (^) followed by hexadecimal values. The values must use lowercase letters! The original version of TeX supported this for 255 characters.

How do I add a Unicode character in HTML?

You can enter any Unicode character in an HTML file by taking its decimal numeric character reference and adding an ampersand and a hash at the front and a semi-colon at the end, for example — should display as an em dash (—). This is the method used in the Unicode test pages.


1 Answers

If by direct you mean using a Unicode code point value, then QChar may be it:

QString s = QChar(0x4FF0); 
like image 67
Stephen Chu Avatar answered Oct 01 '22 23:10

Stephen Chu