It takes 4 bytes for each emoji character and 1 byte for every ASCII character.
package main
import (
"fmt"
)
func main() {
a := []byte("π")
fmt.Println(len(a))
// prints 4
b := []byte("H")
fmt.Println(len(b))
// prints 1
}
It takes 4 bytes for each emoji character and 1 byte for every ASCII character.
package main
import (
"fmt"
)
func main() {
a := []byte("π")
fmt.Println(len(a))
// prints 4
b := []byte("H")
fmt.Println(len(b))
// prints 1
}
UTF-8 perhaps? https://en.wikipedia.org/wiki/UTF-8
Probably not specific to Golang π
What were you working on that led to this, Dwain?
LikeLike
I meant UTF-8 but this was titled for my question as some times people do weird things π and youβre right not specific to Go π.
I played around with some sample code as I learn more about Go.
LikeLike