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) []uint16Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| a | []uint16 | Destination UTF-16 code units to extend. |
| r | rune | Unicode 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, '😀'))}