Standard library / unicode/utf16
utf16.EncodeRune()
Returns the high and low surrogate pair for a supplementary rune; for a rune not requiring a pair, returns two U+FFFD values. Expected stdout: 'd83d de00\n'.
Formal Syntax & Structure
go syntaxgo
func EncodeRune(r rune) (r1, r2 rune)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| r | rune | Unicode code point. |
Return Value
(r1, r2 rune)
Returns the high and low surrogate pair for a supplementary rune; for a rune not requiring a pair, returns two U+FFFD values.
Working Example
Example Snippetgo
package main
import ( "fmt" "unicode/utf16")
func main() { a, b := utf16.EncodeRune('😀') fmt.Printf("%04x %04x\n", a, b)}