golang中byte和rune的区别?

golang中byte和rune的区别?

runebyte在go语言中都是字符类型,从源码来看他们都是别名形式

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码的一个字符

rune类型本质上其实是int32类型的别名,代表的就是一个UTF-8字符

相关推荐
superman超哥14 小时前
仓颉元编程之魂:宏系统的设计哲学与深度实践
开发语言·后端·仓颉编程语言·仓颉·仓颉语言·仓颉语言特性
一 乐14 小时前
健身房预约|基于springboot + vue健身房预约小程序系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端·学习·小程序
CC.GG14 小时前
【C++】哈希表的实现
java·c++·散列表
玄同76514 小时前
Python 数据类型:LLM 语料与 API 参数的底层处理逻辑
开发语言·人工智能·python·自然语言处理·llm·nlp·知识图谱
Slow菜鸟14 小时前
Java基础 | 布隆过滤器
java·开发语言
比奇堡派星星15 小时前
Linux Hotplug 机制详解
linux·开发语言·驱动开发
踏浪无痕15 小时前
JobFlow:时间轮与滑动窗口的实战优化
后端·架构·开源
molaifeng15 小时前
像搭积木一样理解 Golang AST
开发语言·后端·golang
踏浪无痕15 小时前
JobFlow 的延时调度:如何可靠地处理“30分钟后取消订单”
后端·面试·开源
SystickInt15 小时前
C语言 UTC时间转化为北京时间
c语言·开发语言