The default lowest and highest continuation byte.
const ( LoCB = 0x80 // 1000 0000 HiCB = 0xBF // 1011 1111 )
Constants related to getting information of first bytes of UTF-8 sequences.
const ( // ASCII identifies a UTF-8 byte as ASCII. ASCII = as // FirstInvalid indicates a byte is invalid as a first byte of a UTF-8 // sequence. FirstInvalid = xx // SizeMask is a mask for the size bits. Use use x&SizeMask to get the size. SizeMask = 7 // AcceptShift is the right-shift count for the first byte info byte to get // the index into the AcceptRanges table. See AcceptRanges. AcceptShift = 4 )
AcceptRanges is a slice of AcceptRange values. For a given byte sequence b
AcceptRanges[First[b[0]]>>AcceptShift]
will give the value of AcceptRange for the multi-byte UTF-8 sequence starting at b[0].
var AcceptRanges = [...]AcceptRange{ 0: {LoCB, HiCB}, 1: {0xA0, HiCB}, 2: {LoCB, 0x9F}, 3: {0x90, HiCB}, 4: {LoCB, 0x8F}, }
First is information about the first byte in a UTF-8 sequence.
var First = [256]uint8{ as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, as, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s1, s2, s3, s3, s3, s3, s3, s3, s3, s3, s3, s3, s3, s3, s4, s3, s3, s5, s6, s6, s6, s7, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, }
AcceptRange gives the range of valid values for the second byte in a UTF-8 sequence for any value for First that is not ASCII or FirstInvalid.
type AcceptRange struct { Lo uint8 // lowest value for second byte. Hi uint8 // highest value for second byte. }