go-utf8/runereader.go

30 lines
485 B
Go
Raw Normal View History

2022-07-18 23:36:02 +00:00
package utf8
2018-07-11 03:40:40 +00:00
import (
"io"
)
2022-07-18 23:36:02 +00:00
// A utf8.RuneReader implements the io.RuneReader interface by reading from an io.Reader.
2018-07-11 03:40:40 +00:00
type RuneReader struct {
reader io.Reader
}
2022-07-19 04:04:30 +00:00
func RuneReaderWrap(reader io.Reader) RuneReader {
return RuneReader{
2018-07-11 03:40:40 +00:00
reader: reader,
}
}
func (receiver *RuneReader) ReadRune() (rune, int, error) {
2018-07-11 03:56:30 +00:00
if nil == receiver {
return 0, 0, errNilReceiver
}
2018-07-11 03:40:40 +00:00
reader := receiver.reader
if nil == reader {
return 0, 0, errNilReader
}
return ReadRune(reader)
}