Standard library / unicode/utf16

utf16.AppendRune()

Appends the UTF-16 representation of r, using a surrogate pair for supplementary code points and replacement for invalid values. Expected stdout: '[d83d de00]\n'.

Formal Syntax & Structure

go syntaxgo
func AppendRune(a []uint16, r rune) []uint16

Parameters & Attributes

NameTypeDescription
a[]uint16Destination UTF-16 code units to extend.
rruneUnicode code point.

Return Value

[]uint16

Appends the UTF-16 representation of r, using a surrogate pair for supplementary code points and replacement for invalid values.

Working Example

Example Snippetgo
package main
import (  "fmt"  "unicode/utf16")
func main() {  fmt.Printf("%04x\n", utf16.AppendRune(nil, '😀'))}
Go Reference