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.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.