What is “rune” type in Go?

Technology CommunityCategory: GolangWhat is “rune” type in Go?
VietMX Staff asked 3 years ago

There are many other symbols invented by humans other than the ‘abcde..’ symbols. And there are so many that we need 32 bit to encode them.

rune is a builtin type in Go and it’s the alias of int32. rune represents a Unicode CodePoint in Go. It does not matter how many bytes the code point occupies, it can be represented by a rune. For example the rule literal a is in reality the number 97.

A string is not necessarily a sequence of runes. We can convert between string and []rune, but they are different.