[SOLVED]How To Construct a QString from unicode code point beyond u+FFFF?
-
Hi, I want to construct a QString from unicode code point u+1F601, and i tried this:
@QString str(0x1F601);@but failed, am i doing anything wrong? how to do it correcttly?
-
-
Hi SGaist,
Thank you very much, but it did not work. I have found a way to do the job well. Just like below:
@unsigned int ui = 0x1F601;
QString str = QString::fromUcs4(&ui);@ -
Your "solution" is dangerous. QString::fromUcs4() requires a NUL terminated UCS4 string if the length (second) argument is not specified. You are not providing a length or a NUL here. That it does not crash is just a happy coincidence.
@
QString str = QString::fromUcs4(&ui, 1);
@ -
Hi ChrisW67,
Yes, you are right. I forgot the important argument. Thank you!