EncodeRune in Go

Posted by GoDoc
Public (Editable by Users)

EncodeRune writes into p (which must be large enough) the UTF-8 encoding of the rune. It returns the number of bytes written.

Go
Edit
package main

import (
	"fmt"
	"unicode/utf8"
)

func main() {
	r := 'δΈ–'
	buf := make([]byte, 3)

	n := utf8.EncodeRune(buf, r)

	fmt.Println(buf)
	fmt.Println(n)
}