go-utf8/runereader.go

26 lines
432 B
Go
Raw Normal View History

2018-07-11 03:40:40 +00:00
package utf8s
import (
"io"
)
// A utf8s.RuneReader implements the io.RuneReader interface by reading from an io.Reader.
type RuneReader struct {
reader io.Reader
}
func NewRuneReader(reader io.Reader) *RuneReader {
return &RuneReader{
reader: reader,
}
}
func (receiver *RuneReader) ReadRune() (rune, int, error) {
reader := receiver.reader
if nil == reader {
return 0, 0, errNilReader
}
return ReadRune(reader)
}