内容简介:将Unicode编码597D转化为UTF-8编码可以看到utf-8编码是
示例程序
func main() {
var s byte = '?'
fmt.Println(s) //63
//输出 2/8/10 进制格式
fmt.Printf("%b,%o,%d\n", s, s, s) // 111111,77,63
// 以16进制输出字符串
fmt.Printf("%x\n", "hex this")
// 输出数值所表示的 Unicode 字符
fmt.Printf("%c\n", 63)
//输出数值所表示的 Unicode 字符(带单引号)。对于无法显示的字符,将输出其转义字符。
fmt.Printf("%q\n", 63)
//输出 Unicode 码点(例如 U+1234,等同于字符串 "U+%04X" 的显示结果)
fmt.Printf("%U\n", 63)
}
汉字字符集编码查询
http://www.qqxiuzi.cn/bianma/zifuji.php在线进制转换
https://tool.lu/hexconvert/在线Unicode和UTF编码转换
https://www.qqxiuzi.cn/bianma/Unicode-UTF.phpUTF-8编码规则
https://blog.csdn.net/sandyen/article/details/1108168
编码示例
func main() {
var s rune = '好'
fmt.Printf("%d\n",s) // 22909
buf := bytes.NewBufferString("hello")
fmt.Println(buf.Bytes()) // [104 101 108 108 111]
buf.WriteRune(s)
fmt.Println(buf.Bytes()) // [104 101 108 108 111 229 165 189]
}
将Unicode编码597D转化为UTF-8编码
可以看到utf-8编码是 E5A58D ,这是十六进制的,我们转为为10进制
我们要的是字节数组,所以需要将 11100101 10100101 10111101 拆成字节,然后再转化成10进制显示。
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Build Your Own Web Site the Right Way Using HTML & CSS
Ian Lloyd / SitePoint / 2006-05-02 / USD 29.95
Build Your Own Website The Right Way Using HTML & CSS teaches web development from scratch, without assuming any previous knowledge of HTML, CSS or web development techniques. This book introduces you......一起来看看 《Build Your Own Web Site the Right Way Using HTML & CSS》 这本书的介绍吧!