How many bytes are emoji characters in GO?

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

}

2 thoughts on “How many bytes are emoji characters in GO?

  1. 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.

    Like

Leave a Reply