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