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 to Anonymous Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s