I've a string which holds this 🆎 emoji and I wants to store it into sqlite database, this string is coming from server, the string can be in combinations of, only emojis, emojis + text, and only text. How do I handle and store each string I'll get from the server.
I've already code, to store / retrive the texts from the database and its working fine. But when I got an emoji in texts, its changing the output, and instead of an emoji its showing me some random characters like this, 🆎.
How to handle this case?
As per this answer
SQLite always stores text data as Unicode string.
Previosly I was retriving text like this,
NSString *text = [NSString stringWithFormat:@"%s",sqlite3_column_text(statement, 0)];
I changed it to this,
NSString *text = [NSString stringWithUTF8String:(const char *)sqlite3_column_text(statement, 0)];
and its working fine now.
You can send emoji to server in utfstring and for showing emoji in textfield you can change that string into nonlossyasciistringencoding in viewdidload.in this way you can show emoji.
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