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字符

相关推荐
松涛和鸣7 小时前
49、智能电源箱项目技术栈解析
服务器·c语言·开发语言·http·html·php
幽络源小助理7 小时前
springboot校园车辆管理系统源码 – SpringBoot+Vue项目免费下载 | 幽络源
vue.js·spring boot·后端
刀法如飞7 小时前
一款开箱即用的Spring Boot 4 DDD工程脚手架
java·后端·架构
huwei8537 小时前
Q打印表格内容类
开发语言·qt
一嘴一个橘子7 小时前
spring-aop 的 基础使用 -3 - 切点表达式 的提取、复用
java
Re_zero7 小时前
Java新手避坑:为什么我劝你放弃 scanner.nextInt()?
java
oioihoii7 小时前
构建高并发AI服务网关:C++与gRPC的工程实践
开发语言·c++·人工智能
uzong7 小时前
后端系统设计文档模板
后端
幽络源小助理7 小时前
SpringBoot+Vue车票管理系统源码下载 – 幽络源免费项目实战代码
vue.js·spring boot·后端
X***07887 小时前
从底层逻辑到工程实践,深入理解C语言在计算机世界中的核心地位与持久价值
c语言·开发语言