-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemoji_flags.go
42 lines (36 loc) · 1.02 KB
/
emoji_flags.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package emojiflags
import (
"strings"
)
var SpecialEmojiMap = map[string]string{
EnglandCode: "🏴",
ScotlandCode: "🏴",
WalesCode: "🏴",
EnglandShortCode: "🏴",
}
func GetFlag(countryCode string) string {
countryCode = strings.ToUpper(countryCode)
switch len(countryCode) {
case 2:
if code, ok := Cca2CodeMap[countryCode]; ok {
return string(0x1F1E6+rune(code[0])-'A') + string(0x1F1E6+rune(code[1])-'A') + "\u0020"
}
case 3:
if code, ok := Cca3CodeMap[countryCode]; ok {
return string(0x1F1E6+rune(code[0])-'A') + string(0x1F1E6+rune(code[1])-'A') + "\u0020"
}
if code, ok := CiocCodeMap[countryCode]; ok {
return string(0x1F1E6+rune(code[0])-'A') + string(0x1F1E6+rune(code[1])-'A') + "\u0020"
}
if flag, ok := SpecialEmojiMap[countryCode]; ok {
return flag
}
case 6:
if flag, ok := SpecialEmojiMap[countryCode]; ok {
return flag
}
default:
return ""
}
return ""
}