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
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewRuneReader(reader io.Reader) *RuneReader {
|
|
|
|
return &RuneReader{
|
|
|
|
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)
|
|
|
|
}
|