2022-07-18 23:36:02 +00:00
|
|
|
package utf8
|
2019-09-11 19:36:02 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
)
|
|
|
|
|
|
|
|
// RuneWriter writes a single UTF-8 encoded Unicode characters.
|
|
|
|
type RuneWriter struct {
|
|
|
|
writer io.Writer
|
|
|
|
}
|
|
|
|
|
2022-07-19 03:54:16 +00:00
|
|
|
// RuneWriterWrap wraps an io.Writer and returns a RuneWriter.
|
|
|
|
func RuneWriterWrap(writer io.Writer) RuneWriter {
|
|
|
|
return RuneWriter{
|
2019-09-11 19:36:02 +00:00
|
|
|
writer: writer,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// WriteRune writes a single UTF-8 encoded Unicode character and returns the number of bytes written.
|
|
|
|
func (receiver *RuneWriter) WriteRune(r rune) (int, error) {
|
|
|
|
if nil == receiver {
|
|
|
|
return 0, errNilReceiver
|
|
|
|
}
|
|
|
|
|
|
|
|
return WriteRune(receiver.writer, r)
|
|
|
|
}
|