Standard library / bytes
bytes.Reader.ReadRune()
Decodes the next rune and advances by its byte width; malformed UTF-8 consumes one byte as RuneError. At EOF returns an error. Expected stdout: 'é 2 <nil>\n'.
Formal Syntax & Structure
go syntaxgo
func (r *Reader) ReadRune() (ch rune, size int, err error)Return Value
(ch rune, size int, err error)
Decodes the next rune and advances by its byte width; malformed UTF-8 consumes one byte as RuneError. At EOF returns an error.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt")
func main() { r := bytes.NewReader([]byte("aé")) r.ReadByte() v, n, e := r.ReadRune() fmt.Println(string(v), n, e)}