MCPcopy
hub / github.com/pquerna/ffjson / ReadRune

Method ReadRune

fflib/v1/buffer.go:350–364  ·  view source on GitHub ↗

ReadRune reads and returns the next UTF-8-encoded Unicode code point from the buffer. If no bytes are available, the error returned is io.EOF. If the bytes are an erroneous UTF-8 encoding, it consumes one byte and returns U+FFFD, 1.

()

Source from the content-addressed store, hash-verified

348// If the bytes are an erroneous UTF-8 encoding, it
349// consumes one byte and returns U+FFFD, 1.
350func (b *Buffer) ReadRune() (r rune, size int, err error) {
351 if b.off >= len(b.buf) {
352 // Buffer is empty, reset to recover space.
353 b.Truncate(0)
354 return 0, 0, io.EOF
355 }
356 c := b.buf[b.off]
357 if c < utf8.RuneSelf {
358 b.off++
359 return rune(c), 1, nil
360 }
361 r, n := utf8.DecodeRune(b.buf[b.off:])
362 b.off += n
363 return r, n, nil
364}
365
366// ReadBytes reads until the first occurrence of delim in the input,
367// returning a slice containing the data up to and including the delimiter.

Callers

nothing calls this directly

Calls 1

TruncateMethod · 0.95

Tested by

no test coverage detected