Standard library / strings

strings.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 (  "fmt"  "strings")
func main() {  r := strings.NewReader("aé")  r.ReadByte()  v, n, e := r.ReadRune()  fmt.Println(string(v), n, e)}
Go Reference