go - 在go中用UTF-8格式编码字符串

标签 go utf-8

<分区>

golang(go语言)中如何将字符串文本转为utf8?

最佳答案

go 中的字符串文字默认使用 UTF-8 编码。 来自official golang blog

Go source code is UTF-8, so the source code for the string literal is UTF-8 text

但这不适用于转义字符,例如 \n:

If that string literal contains no escape sequences, which a raw string cannot, the constructed string will hold exactly the source text between the quotes.

希望这对您有所帮助!

关于go - 在go中用UTF-8格式编码字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40082833/

相关文章:

Java解析txt文件意外字符

go - NSQ 重新队列半消息

parsing - 如何正确解析时区代码

session - 在 golang 中检查 HTML 文件中的用户 session

c++ - UTF8 到/从 STL 中的宽字符转换

php - UTF-8贯穿始终

javascript - 使用 websockets Golang 将更改推送到客户端

go - 将图像从 *image.YCbCr 转换为 *image.RGBA

validation - 为什么Firefox中的DOCTYPE行是红色的?

php - 如何将 Windows-1251 转码为 UTF-8?