runes

package
v0.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadAll

func ReadAll(r Reader) ([]rune, error)

ReadAll reads from r until an error or EOF and returns the data.

Types

type Reader

type Reader interface {
	Read(data []rune) (int, error)
}

Reader is the interface that wraps the basic Read method.

Read reads up to len(data) runes into data. It returns the number of runes read (0 <= n <= len(data)) and any error encountered. Even if Read returns n < len(data), it may use all of data as scratch space during the call. If some data is available but not len(data) runes, Read conventionally returns what is available instead of waiting for more.

When Read encounters an error or end-of-file condition after successfully reading n > 0 runes, it returns the number of runes read. It may return the (non-nil) error from the same call or return the error (and n == 0) from a subsequent call. An instance of this general case is that a Reader returning a non-zero number of runes at the end of the input stream may return either err == EOF or err == nil. The next Read should return 0, EOF.

Callers should always process the n > 0 runes returned before considering the error err. Doing so correctly handles I/O errors that happen after reading some runes and also both of the allowed EOF behaviors.

Implementations of Read are discouraged from returning a zero rune count with a nil error, except when len(data) == 0. Callers should treat a return of 0 and nil as indicating that nothing happened; in particular it does not indicate EOF.

Implementations must not retain data.

type UnicodeReader

type UnicodeReader struct {
	// contains filtered or unexported fields
}

UnicodeReader wraps an `io.RuneReader` in a `Reader` interface.

func NewUnicodeReader

func NewUnicodeReader(r io.RuneReader) *UnicodeReader

NewUnicodeReader implements a runes.Reader interface from a io.RuneReader interface.

func (*UnicodeReader) Read

func (r *UnicodeReader) Read(data []rune) (int, error)

Read implements the runes.Reader interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL