diff --git a/emoji/map.go b/emoji/map.go index 10a304c..2681489 100644 --- a/emoji/map.go +++ b/emoji/map.go @@ -1,6 +1,7 @@ package emoji import ( + "encoding/hex" "fmt" "strconv" "strings" @@ -72,3 +73,24 @@ func CodepointToUnicode(word string) string { } return ret } + +// FromHexString parses string s as two character byte of hexadecimal into +// Unicode Codepoint +func FromHexString(s string) (string, error) { + d, err := hex.DecodeString(s) + if err != nil { + return "", err + } + + var ret string + for _, b := range d { + for _, e := range Map(b) { + // use the first colon notation word and continue + if IsCodepoint(e) { + ret = ret + CodepointToUnicode(e) + break + } + } + } + return ret, nil +}