Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[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:
but failed, am i doing anything wrong? how to do it correcttly?
Unless I'm mistaken, something like
should do the job
Hope it helps
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);@
ChrisW67 last edited by
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);
Yes, you are right. I forgot the important argument. Thank you!