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));
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.
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.
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.
If by direct you mean using a Unicode code point value, then QChar
may be it:
QString s = QChar(0x4FF0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With