Skip to content

Commit

Permalink
Correctly decode emoji data as UTF-8 (#11)
Browse files Browse the repository at this point in the history
* Correctly decode emoji data as UTF-8

* Add tests
  • Loading branch information
abitofevrything authored Sep 11, 2023
1 parent 5906fb1 commit 3847d38
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/emoji.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Future<List<EmojiDefinition>> getEmojiDefinitions() async {
return _cachedEmojiDefinitions!;
} else {
final response = await http.get(_emojiDefinitionsUrl);
final data = jsonDecode(response.body)['emojiDefinitions'];
final data = jsonDecode(utf8.decode(response.bodyBytes))['emojiDefinitions'];

_cachedAt = DateTime.timestamp();
return _cachedEmojiDefinitions = [
Expand Down
6 changes: 6 additions & 0 deletions test/integration/emoji_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ void main() {

expect(emojis, isNotEmpty);
});

test('getEmojiDefinitions correcly decodes emojis', () async {
final emoji = (await getEmojiDefinitions()).singleWhere((element) => element.primaryName == 'heart');

expect(emoji.surrogates, equals('❤️'));
});
}

0 comments on commit 3847d38

Please sign in to comment.