golang中byte和rune的区别?
rune
和byte
在go语言中都是字符类型,从源码来看他们都是别名形式
// byte is an alias for uint8 and is equivalent to uint8 in all ways. It is
// used, by convention, to distinguish byte values from 8-bit unsigned
// integer values.
type byte = uint8
// rune is an alias for int32 and is equivalent to int32 in all ways. It is
// used, by convention, to distinguish character values from integer values.
type rune = int32
byte
类型本质上是uint8类型的别名,代表的就是ascll码的一个字符文章来源:https://www.toymoban.com/news/detail-693267.html
rune
类型本质上其实是int32类型的别名,代表的就是一个UTF-8字符文章来源地址https://www.toymoban.com/news/detail-693267.html
到了这里,关于golang中byte和rune的区别?的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!