Add emoji support
This commit is contained in:
45
dictionary/sets/emoji.go
Normal file
45
dictionary/sets/emoji.go
Normal file
@ -0,0 +1,45 @@
|
||||
package sets
|
||||
|
||||
func emojiGenerateFromUnicodeRange(start, end rune) []int {
|
||||
var emojis []int
|
||||
for emoji := start; emoji <= end; emoji++ {
|
||||
emojis = append(emojis, int(emoji))
|
||||
|
||||
// Variations with variation selectors
|
||||
for vs := rune(0xFE00); vs <= rune(0xFE0F); vs++ {
|
||||
combined := []rune{emoji, vs}
|
||||
combinedStr := string(combined)
|
||||
emojis = append(emojis, int([]rune(combinedStr)[0]))
|
||||
}
|
||||
|
||||
// Variations with skin tone modifiers
|
||||
for st := rune(0x1F3FB); st <= rune(0x1F3FF); st++ {
|
||||
combined := []rune{emoji, st}
|
||||
combinedStr := string(combined)
|
||||
emojis = append(emojis, int([]rune(combinedStr)[0]))
|
||||
}
|
||||
}
|
||||
return emojis
|
||||
}
|
||||
|
||||
func Emoji() (dict []int) {
|
||||
// Unicode ranges for emojis
|
||||
ranges := [][]rune{
|
||||
{0x1F600, 0x1F64F}, // Emoticons
|
||||
{0x1F300, 0x1F5FF}, // Miscellaneous Symbols and Pictographs
|
||||
{0x1F900, 0x1F9FF}, // Supplemental Symbols and Pictographs
|
||||
{0x1F1E6, 0x1F1FF}, // Enclosed Alphanumeric Supplement (for flags)
|
||||
{0x1F680, 0x1F6FF}, // Transport and Map Symbols
|
||||
{0x2600, 0x26FF}, // Miscellaneous Symbols
|
||||
{0x2700, 0x27BF}, // Dingbats
|
||||
{0xFE00, 0xFE0F}, // Variation Selectors
|
||||
{0x1F1E6, 0x1F1FF}, // Regional Indicator Symbols
|
||||
{0xE0030, 0xE0039}, // Variation Selectors Supplement
|
||||
}
|
||||
|
||||
for _, r := range ranges {
|
||||
dict = append(dict, emojiGenerateFromUnicodeRange(r[0], r[1])...)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
Reference in New Issue
Block a user