@@ -507,6 +507,35 @@ enum UserTopicVisibilityPolicy {
507507 int ? toJson () => apiValue;
508508}
509509
510+ /// Convert a Unicode emoji's Zulip "emoji code" into the
511+ /// actual Unicode code points.
512+ ///
513+ /// The argument corresponds to [Reaction.emojiCode] when [Reaction.emojiType]
514+ /// is [ReactionType.unicodeEmoji] . For docs, see:
515+ /// https://zulip.com/api/add-reaction#parameter-reaction_type
516+ ///
517+ /// In addition to reactions, these appear in Zulip content HTML;
518+ /// see [UnicodeEmojiNode.emojiUnicode] .
519+ String ? tryParseEmojiCodeToUnicode (String emojiCode) {
520+ // Ported from: https://github.com/zulip/zulip-mobile/blob/c979530d6804db33310ed7d14a4ac62017432944/src/emoji/data.js#L108-L112
521+ // which refers to a comment in the server implementation:
522+ // https://github.com/zulip/zulip/blob/63c9296d5339517450f79f176dc02d77b08020c8/zerver/models.py#L3235-L3242
523+ // In addition to what's in the doc linked above, that comment adds:
524+ //
525+ // > For examples, see "non_qualified" or "unified" in the following data,
526+ // > with "non_qualified" taking precedence when both present:
527+ // > https://raw.githubusercontent.com/iamcal/emoji-data/a8174c74675355c8c6a9564516b2e961fe7257ef/emoji_pretty.json
528+ // > [link fixed to permalink; original comment says "master" for the commit]
529+ try {
530+ return String .fromCharCodes (emojiCode.split ('-' )
531+ .map ((hex) => int .parse (hex, radix: 16 )));
532+ } on FormatException { // thrown by `int.parse`
533+ return null ;
534+ } on ArgumentError { // thrown by `String.fromCharCodes`
535+ return null ;
536+ }
537+ }
538+
510539/// As in the get-messages response.
511540///
512541/// https://zulip.com/api/get-messages#response
0 commit comments