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) []byteParameters & Attributes
| Name | Type | Description |
|---|---|---|
| p | []byte | Byte slice to extend; retain the returned slice. |
| r | rune | Unicode 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"), 'é'))}