MaxRune const #
Numbers fundamental to the encoding.
const MaxRune = '\U0010FFFF'
Numbers fundamental to the encoding.
const MaxRune = '\U0010FFFF'
Numbers fundamental to the encoding.
const RuneError = '\uFFFD'
Numbers fundamental to the encoding.
const RuneSelf = 0x80
Numbers fundamental to the encoding.
const UTFMax = 4
acceptRanges has size 16 to avoid bounds checks in the code that uses it.
var acceptRanges = [16]acceptRange{...}
const as = 0xF0
first is information about the first byte in a UTF-8 sequence.
var first = [256]uint8{...}
const hicb = 0b10111111
The default lowest and highest continuation byte.
const locb = 0b10000000
const mask2 = 0b00011111
const mask3 = 0b00001111
const mask4 = 0b00000111
const maskx = 0b00111111
const rune1Max = *ast.BinaryExpr
const rune2Max = *ast.BinaryExpr
const rune3Max = *ast.BinaryExpr
const runeErrorByte0 = *ast.BinaryExpr
const runeErrorByte1 = *ast.BinaryExpr
const runeErrorByte2 = *ast.BinaryExpr
const s1 = 0x02
const s2 = 0x13
const s3 = 0x03
const s4 = 0x23
const s5 = 0x34
const s6 = 0x04
const s7 = 0x44
Code points in the surrogate range are not valid for UTF-8.
const surrogateMax = 0xDFFF
Code points in the surrogate range are not valid for UTF-8.
const surrogateMin = 0xD800
const t1 = 0b00000000
const t2 = 0b11000000
const t3 = 0b11100000
const t4 = 0b11110000
const t5 = 0b11111000
const tx = 0b10000000
These names of these constants are chosen to give nice alignment in the table below. The first nibble is an index into acceptRanges or F for special one-byte cases. The second nibble is the Rune length or the Status for the special one-byte case.
const xx = 0xF1
acceptRange gives the range of valid values for the second byte in a UTF-8 sequence.
type acceptRange struct {
lo uint8
hi uint8
}
AppendRune appends the UTF-8 encoding of r to the end of p and returns the extended buffer. If the rune is out of range, it appends the encoding of [RuneError].
func AppendRune(p []byte, r rune) []byte
DecodeLastRune unpacks the last UTF-8 encoding in p and returns the rune and its width in bytes. If p is empty it returns ([RuneError], 0). Otherwise, if the encoding is invalid, it returns (RuneError, 1). Both are impossible results for correct, non-empty UTF-8. An encoding is invalid if it is incorrect UTF-8, encodes a rune that is out of range, or is not the shortest possible UTF-8 encoding for the value. No other validation is performed.
func DecodeLastRune(p []byte) (r rune, size int)
DecodeLastRuneInString is like [DecodeLastRune] but its input is a string. If s is empty it returns ([RuneError], 0). Otherwise, if the encoding is invalid, it returns (RuneError, 1). Both are impossible results for correct, non-empty UTF-8. An encoding is invalid if it is incorrect UTF-8, encodes a rune that is out of range, or is not the shortest possible UTF-8 encoding for the value. No other validation is performed.
func DecodeLastRuneInString(s string) (r rune, size int)
DecodeRune unpacks the first UTF-8 encoding in p and returns the rune and its width in bytes. If p is empty it returns ([RuneError], 0). Otherwise, if the encoding is invalid, it returns (RuneError, 1). Both are impossible results for correct, non-empty UTF-8. An encoding is invalid if it is incorrect UTF-8, encodes a rune that is out of range, or is not the shortest possible UTF-8 encoding for the value. No other validation is performed.
func DecodeRune(p []byte) (r rune, size int)
DecodeRuneInString is like [DecodeRune] but its input is a string. If s is empty it returns ([RuneError], 0). Otherwise, if the encoding is invalid, it returns (RuneError, 1). Both are impossible results for correct, non-empty UTF-8. An encoding is invalid if it is incorrect UTF-8, encodes a rune that is out of range, or is not the shortest possible UTF-8 encoding for the value. No other validation is performed.
func DecodeRuneInString(s string) (r rune, size int)
EncodeRune writes into p (which must be large enough) the UTF-8 encoding of the rune. If the rune is out of range, it writes the encoding of [RuneError]. It returns the number of bytes written.
func EncodeRune(p []byte, r rune) int
FullRune reports whether the bytes in p begin with a full UTF-8 encoding of a rune. An invalid encoding is considered a full Rune since it will convert as a width-1 error rune.
func FullRune(p []byte) bool
FullRuneInString is like FullRune but its input is a string.
func FullRuneInString(s string) bool
RuneCount returns the number of runes in p. Erroneous and short encodings are treated as single runes of width 1 byte.
func RuneCount(p []byte) int
RuneCountInString is like [RuneCount] but its input is a string.
func RuneCountInString(s string) (n int)
RuneLen returns the number of bytes in the UTF-8 encoding of the rune. It returns -1 if the rune is not a valid value to encode in UTF-8.
func RuneLen(r rune) int
RuneStart reports whether the byte could be the first byte of an encoded, possibly invalid rune. Second and subsequent bytes always have the top two bits set to 10.
func RuneStart(b byte) bool
Valid reports whether p consists entirely of valid UTF-8-encoded runes.
func Valid(p []byte) bool
ValidRune reports whether r can be legally encoded as UTF-8. Code points that are out of range or a surrogate half are illegal.
func ValidRune(r rune) bool
ValidString reports whether s consists entirely of valid UTF-8-encoded runes.
func ValidString(s string) bool
func appendRuneNonASCII(p []byte, r rune) []byte
func encodeRuneNonASCII(p []byte, r rune) int
Generated with Arrow