Standard library / bytes
bytes.Buffer.WriteRune()
Appends UTF-8 encoding of r, returning byte count and nil error; invalid rune becomes U+FFFD. Expected stdout: '2 <nil> é\n'.
Formal Syntax & Structure
go syntaxgo
func (b *Buffer) WriteRune(r rune) (n int, err error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| r | rune | Data to append or write. |
Return Value
(n int, err error)
Appends UTF-8 encoding of r, returning byte count and nil error; invalid rune becomes U+FFFD.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt")
func main() { var b bytes.Buffer n, e := b.WriteRune('é') fmt.Println(n, e, b.String())}