Standard library / unicode/utf8

utf8.AppendRune()

Appends the UTF-8 encoding of r; invalid code points encode RuneError. Keep the returned slice. Expected stdout: '61c3a9\n'.

Formal Syntax & Structure

go syntaxgo
func AppendRune(p []byte, r rune) []byte

Parameters & Attributes

NameTypeDescription
p[]byteByte slice to extend; retain the returned slice.
rruneUnicode code point.

Return Value

[]byte

Appends the UTF-8 encoding of r; invalid code points encode RuneError. Keep the returned slice.

Working Example

Example Snippetgo
package main
import (  "fmt"  "unicode/utf8")
func main() {  fmt.Printf("%x\n", utf8.AppendRune([]byte("a"), 'é'))}
Go Reference