go-utf8/runereader.go

30 lines
486 B
Go

package utf8
import (
"io"
)
// A utf8.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) {
if nil == receiver {
return 0, 0, errNilReceiver
}
reader := receiver.reader
if nil == reader {
return 0, 0, errNilReader
}
return ReadRune(reader)
}