golang中byte和rune的區(qū)別?
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
類型本質(zhì)上是uint8類型的別名,代表的就是ascll碼的一個字符文章來源:http://www.zghlxwxcb.cn/news/detail-693267.html
rune
類型本質(zhì)上其實是int32類型的別名,代表的就是一個UTF-8字符文章來源地址http://www.zghlxwxcb.cn/news/detail-693267.html
到了這里,關(guān)于golang中byte和rune的區(qū)別?的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!