Emojis are not getting displayed in text received from api call, flutter
Asked Answered
D

2

6

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.

Screen shot of emulator

Diacid answered 12/4, 2022 at 12:42 Comment(1)
Check here. โ€“ Ramin
L
11

Pass your string in this method!

String utf8convert(String text) {
    List<int> bytes = text.toString().codeUnits;
    return utf8.decode(bytes);
  }
Lavaliere answered 24/7, 2022 at 9:33 Comment(0)
T
0

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

Tusche answered 21/5 at 6:59 Comment(0)

© 2022 - 2024 โ€” McMap. All rights reserved.