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 = 0x80Numbers fundamental to the encoding.
const UTFMax = 4acceptRanges has size 16 to avoid bounds checks in the code that uses it.
var acceptRanges = [16]acceptRange{...}const as = 0xF0first is information about the first byte in a UTF-8 sequence.
var first = [256]uint8{...}const hicb = 0b10111111The default lowest and highest continuation byte.
const locb = 0b10000000const mask2 = 0b00011111const mask3 = 0b00001111const mask4 = 0b00000111const maskx = 0b00111111const rune1Max = *ast.BinaryExprconst rune2Max = *ast.BinaryExprconst rune3Max = *ast.BinaryExprconst runeErrorByte0 = *ast.BinaryExprconst runeErrorByte1 = *ast.BinaryExprconst runeErrorByte2 = *ast.BinaryExprconst s1 = 0x02const s2 = 0x13const s3 = 0x03const s4 = 0x23const s5 = 0x34const s6 = 0x04const s7 = 0x44Code points in the surrogate range are not valid for UTF-8.
const surrogateMax = 0xDFFFCode points in the surrogate range are not valid for UTF-8.
const surrogateMin = 0xD800const t1 = 0b00000000const t2 = 0b11000000const t3 = 0b11100000const t4 = 0b11110000const t5 = 0b11111000const tx = 0b10000000These 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 = 0xF1acceptRange 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) []byteDecodeLastRune 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) intFullRune 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) boolFullRuneInString is like FullRune but its input is a string.
func FullRuneInString(s string) boolRuneCount returns the number of runes in p. Erroneous and short encodings are treated as single runes of width 1 byte.
func RuneCount(p []byte) intRuneCountInString 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) intRuneStart 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) boolValid reports whether p consists entirely of valid UTF-8-encoded runes.
func Valid(p []byte) boolValidRune 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) boolValidString reports whether s consists entirely of valid UTF-8-encoded runes.
func ValidString(s string) boolfunc appendRuneNonASCII(p []byte, r rune) []bytefunc encodeRuneNonASCII(p []byte, r rune) intGenerated with Arrow