I'm building a map of emoji unified unicode characters to their common names. I have strings representing each emoji, in UTF16 format. For example, the string "00A9" represents the copyright symbol. I need to convert that into a utf8 rune, so I can compare it to input I receive from the user, but I haven't found the right incantation of the hex/utf16/utf8 packages to do so.
2条回答 默认 最新
- donglieshe4692 2016-10-19 01:07关注
Parse the hex string as an integer. Use a string conversion to convert the integer to UTF-8.
n, err := strconv.ParseInt("00A9", 16, 32) if err != nil { log.Fatal(err) } s := string(n)
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报