内容简介:将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进制显示。
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Writing Apache Modules with Perl and C
Lincoln Stein、Doug MacEachern / O'Reilly Media, Inc. / 1999-03 / USD 39.95
Apache is the most popular Web server on the Internet because it is free, reliable, and extensible. The availability of the source code and the modular design of Apache makes it possible to extend Web......一起来看看 《Writing Apache Modules with Perl and C》 这本书的介绍吧!