Unsolved ios emoji unicode
-
I failed to get the emoji work on ios and hope someone could offer some suggestion.
I store emoji's unicode, utf8, utf16, image file name in sqlite and query data by QSqlQueryModel. Since the qml add emoji like this on ios: text{text:"\uD83D\uDCA9"}, i write the following code to convert emoji's utf16 just like that format.
@QByteArray SqlQueryModel::convertStringTest(QString qString)
{
qDebug() << qString;
QString result = qString;
QStringList qStringList = qString.split("0x", QString::SkipEmptyParts);
if(qStringList.size() >= 2)
{
result = "\u" + qStringList[0].trimmed() + "\u" + qStringList[1];
}
else
result = "\u" + qStringList[0];
qDebug() << result; //the result is "\uD83D\uDCA9"return result;
}
in qml, i call the function as:
@text
{
text: emojiListModel.convertStringTest(utf16); // the utf16's value is "0xD83D 0xDE04" with a database format of TEXT
}@The it is always display "\uD83D\uDCA9" on ipad but not the emoji. Then i add console.log to print the result of emojiListModel.convertStringTest(utf16) in qml.
@function test(utf16str)
{
var str1 = utf16str; //value is "\uD83D\uDCA9"
var str2 = "\uD83D\uDCA9";
console.log(str1); //display string "\uD83D\uDCA9"
console.log(str2); //display emojireturn str1; }@
I have no idea why this not work?