【发布时间】:2014-10-17 13:29:47
【问题描述】:
我使用下面的代码生成字符串str的XML编码:
str := string([]byte{0x01})
marshalBytes, _ := xml.Marshal(str)
fmt.Println(string(marshalBytes)) // output: <string>�</string>; � is [239 191 189] in bytes.
显然, � 不等于 0x01。
我该如何解决?
【问题讨论】:
-
您是在 Windows 上,还是在 DOS 窗口中? (如stackoverflow.com/q/12053168/6309)
-
我在 osx 上。 Charlie Tumahai 给出了答案。