Source File
read_rune.go
Belonging Package
src.elv.sh/pkg/cli/term
package termimport ()type byteReaderWithTimeout interface {// ReadByteWithTimeout reads a single byte with a timeout. A negative// timeout means no timeout.ReadByteWithTimeout(timeout time.Duration) (byte, error)}const badRune = '\ufffd'var utf8SeqTimeout = 10 * time.Millisecond// Reads a rune from the reader. The timeout applies to the first byte; a// negative value means no timeout.func ( byteReaderWithTimeout, time.Duration) (rune, error) {, := .ReadByteWithTimeout()if != nil {return badRune,}var rune:= 0switch {case >>7 == 0:= rune()case >>5 == 0x6:= rune( & 0x1f)= 1case >>4 == 0xe:= rune( & 0xf)= 2case >>3 == 0x1e:= rune( & 0x7)= 3}for := 0; < ; ++ {, := .ReadByteWithTimeout(utf8SeqTimeout)if != nil {return badRune,}= <<6 + rune(&0x3f)}return , nil}
The pages are generated with Golds v0.2.8-preview. (GOOS=darwin GOARCH=arm64)