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)
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 C语言快速排序函数纠错
- ¥15 C#的一个应用程序书写
- ¥65 页面调接口时加载卡住不响应
- ¥35 用C语言解决编程问题
- ¥15 unity硬件连接与使用
- ¥15 鱼缸加热棒的数据分析或者实际案例也行
- ¥15 postgresql11安装完成后,pgadmin无法启动
- ¥15 (标签-无人机|关键词-Matlab代码)
- ¥15 执行shell脚本提示参数太多
- ¥15 困扰好久了,电脑的串口调试助手向单片机发送一个字符(如:字符‘1’到‘8’),单片机点亮对应的灯(如发送字符‘2’则点亮第2个灯)并给电脑回复信息:已点亮第x个灯(其中 x 要替换成对应的数字)