Reputation: 633
I am trying to display text which includes emojis from a string received in API response. The text is displaying properly but the emojis are getting displayed as some foreign characters. Please let me know how to fix this. Thanks.
Emojis in the text should be like this: 'So, how are you finding this app? 😄😅 Spare a min to rate it.'
But it is getting displayed as below.
Upvotes: 6
Views: 1541
Reputation: 1362
Try this
final response = http.get(Uri.parse("https://example.com/chats"));
final decodedResponse = json.decode(utf8.decode(response.bodyBytes, allowMalformed: true));
If not worked, Check your database encoding. For Postgres run this command to know encoding
SHOW SERVER_ENCODING
Upvotes: -1
Reputation: 685
Pass your string in this method!
String utf8convert(String text) {
List<int> bytes = text.toString().codeUnits;
return utf8.decode(bytes);
}
Upvotes: 11