dou4064
2019-04-16 03:30
采纳率: 100%
浏览 480
已采纳

GoLang从文件中加载的Unicode文字打印表情符号

I am attempting to print Unicode emoji characters loaded from a JSON file using GoLang. When I load and unmarshall my file, the struct field passed to fmt.Println, only prints the escaped string sequence. For example, one string is stored within the file as {..."Unicode":"\\U0001f47f"} and printing it yields \U0001f417 and not the emoji character. Calling fmt.Printf("%q", str) yields \\U0001f417. I wasn't able to find a solution and I am bit stumped. I have attempted to remove the escape sequence and concatenate it within a template string, but it has no impact. I also attempted to use a string buffer but it didn't work either. Any advice is very much appreciated!

图片转代码服务由CSDN问答提供 功能建议

我正在尝试打印使用GoLang从JSON文件加载的Unicode表情符号字符。 当我加载和解组文件时,传递给 fmt.Println </ code>的struct字段仅打印转义的字符串序列。 例如,一个字符串以 {...“ Unicode”:“ \\ U0001f47f”} </ code>的形式存储在文件中,并将其打印将产生 \ U0001f417 </ code>而不是表情符号字符 。 调用 fmt.Printf(“%q”,str)</ code>会产生 \\ U0001f417 </ code>。 我找不到解决方案,我有些困惑。 我试图删除转义序列并将其连接在模板字符串中,但这没有影响。 我也尝试使用字符串缓冲区,但是它也不起作用。 任何建议都非常感谢!</ p> </ div>

2条回答 默认 最新

相关推荐 更多相似问题