@@ -35,6 +35,16 @@ export const EMOTICON_TO_EMOJI = new Map<string, IEmoji>();
3535
3636export const getEmojiFromUnicode = unicode => UNICODE_TO_EMOJI . get ( stripVariation ( unicode ) ) ;
3737
38+ const isRegionalIndicator = ( x : string ) : boolean => {
39+ // First verify that the string is a single character. We use Array.from
40+ // to make sure we count by characters, not UTF-8 code units.
41+ return Array . from ( x ) . length === 1 &&
42+ // Next verify that the character is within the code point range for
43+ // regional indicators.
44+ // http://unicode.org/charts/PDF/Unicode-6.0/U60-1F100.pdf
45+ x >= '\u{1f1e6}' && x <= '\u{1f1ff}' ;
46+ } ;
47+
3848const EMOJIBASE_GROUP_ID_TO_CATEGORY = [
3949 "people" , // smileys
4050 "people" , // actually people
@@ -72,7 +82,11 @@ export const EMOJI: IEmoji[] = EMOJIBASE.map((emojiData: Omit<IEmoji, "shortcode
7282 shortcodes : typeof shortcodeData === "string" ? [ shortcodeData ] : shortcodeData ,
7383 } ;
7484
75- const categoryId = EMOJIBASE_GROUP_ID_TO_CATEGORY [ emoji . group ] ;
85+ // We manually include regional indicators in the symbols group, since
86+ // Emojibase intentionally leaves them uncategorized
87+ const categoryId = EMOJIBASE_GROUP_ID_TO_CATEGORY [ emoji . group ] ??
88+ ( isRegionalIndicator ( emoji . unicode ) ? "symbols" : null ) ;
89+
7690 if ( DATA_BY_CATEGORY . hasOwnProperty ( categoryId ) ) {
7791 DATA_BY_CATEGORY [ categoryId ] . push ( emoji ) ;
7892 }
0 commit comments