Standard library / bufio
bufio.Writer.WriteRune()
Encodes a rune as UTF-8 and writes its bytes; returns encoded byte count and error. Expected stdout: '2 é <nil>\n'.
Formal Syntax & Structure
go syntaxgo
func (b *Writer) WriteRune(r rune) (size int, err error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| r | rune | Source reader. |
Return Value
(size int, err error)
Encodes a rune as UTF-8 and writes its bytes; returns encoded byte count and error.
Working Example
Example Snippetgo
package main
import ( "bufio" "bytes" "fmt")
func main() { var b bytes.Buffer w := bufio.NewWriter(&b) n, e := w.WriteRune('é') w.Flush() fmt.Println(n, b.String(), e)}