// validUTF8 reports whether the byte pair can appear in a
// valid sequence of UTF-8-encoded code points.
19455
func validUTF8(c1, c2 uint32) bool {
	switch {
	case c1 < 0x80:
		// 1-byte, must be followed by 1-byte or first of multi-byte
		return c2 < 0x80 || 0xc0 <= c2 && c2 < 0xf8
	case c1 < 0xc0:
		// continuation byte, can be followed by nearly anything
		return c2 < 0xf8
	case c1 < 0xf8:
		// first of multi-byte, must be followed by continuation byte
		return 0x80 <= c2 && c2 < 0xc0
	}
	return false
}
675755
func (e *Encoder) EncodeUint8(n uint8) error {
	return e.write1(codes.Uint8, n)
}
297727
func isUnicode(s string) bool {
	for _, c := range []byte(s) {
		// For legacy reasons, 0x80 is not considered a Unicode character.
		if c > 0x80 {
			return true
		}
	}
	return false
}
435585
func IsUTFNumeric(s string) bool {
	for _, v := range s {
		if unicode.IsNumber(v) == false {
			return false
		}
	}
	return true
}
781173
func utf8toutf16(s string) string {
	res := make([]byte, 0, 8)
	res = append(res, 0xFE, 0xFF)
	nb := len(s)
	i := 0
	for i < nb {
		c1 := byte(s[i])
		i++
		switch {
		case c1 >= 224:
			// 3-byte character
			c2 := byte(s[i])
			i++
			c3 := byte(s[i])
			i++
			res = append(res, ((c1&0x0F)<<4)+((c2&0x3C)>>2),
				((c2&0x03)<<6)+(c3&0x3F))
		case c1 >= 192:
			// 2-byte character
			c2 := byte(s[i])
			i++
			res = append(res, ((c1 & 0x1C) >> 2),
				((c1&0x03)<<6)+(c2&0x3F))
		default:
			// Single-byte character
			res = append(res, 0, c1)
		}
	}
	return string(res)
}
479750
func ValidLangCode(c string) bool {
	for d := range LangCodes {
		if c == d {
			return true
		}
	}
	return false
}
1239220
func (ut UserType) Valid() (err error) {
	switch ut {
	case Owner: // 1
	case Member: // 2
	default:
		err = ErrInvalidUserType
	}

	return err
}
1259386
func (stream *Stream) WriteUint8(val uint8) {
	stream.buf = writeFirstBuf(stream.buf, digits[val])
}
966683
public static void validateUTF8(byte[] utf8, int start, int len) throws MalformedInputException {
        int count = start;
        int leadByte = 0;
        int length = 0;
        int state = LEAD_BYTE;
        while (count < start + len) {
            int aByte = ((int) utf8[count] & 0xFF);

            switch (state) {
                case LEAD_BYTE:
                    leadByte = aByte;
                    length = bytesFromUTF8[aByte];

                    switch (length) {
                        case 0: // check for ASCII
                            if (leadByte > 0x7F)
                                throw new MalformedInputException(count);
                            break;
                        case 1:
                            if (leadByte < 0xC2 || leadByte > 0xDF)
                                throw new MalformedInputException(count);
                            state = TRAIL_BYTE_1;
                            break;
                        case 2:
                            if (leadByte < 0xE0 || leadByte > 0xEF)
                                throw new MalformedInputException(count);
                            state = TRAIL_BYTE_1;
                            break;
                        case 3:
                            if (leadByte < 0xF0 || leadByte > 0xF4)
                                throw new MalformedInputException(count);
                            state = TRAIL_BYTE_1;
                            break;
                        default:
                            // too long! Longest valid UTF-8 is 4 bytes (lead + three)
                            // or if < 0 we got a trail byte in the lead byte position
                            throw new MalformedInputException(count);
                    } // switch (length)
                    break;

                case TRAIL_BYTE_1:
                    if (leadByte == 0xF0 && aByte < 0x90)
                        throw new MalformedInputException(count);
                    if (leadByte == 0xF4 && aByte > 0x8F)
                        throw new MalformedInputException(count);
                    if (leadByte == 0xE0 && aByte < 0xA0)
                        throw new MalformedInputException(count);
                    if (leadByte == 0xED && aByte > 0x9F)
                        throw new MalformedInputException(count);
                    // falls through to regular trail-byte test!!
                case TRAIL_BYTE:
                    if (aByte < 0x80 || aByte > 0xBF)
                        throw new MalformedInputException(count);
                    if (--length == 0) {
                        state = LEAD_BYTE;
                    } else {
                        state = TRAIL_BYTE;
                    }
                    break;
            } // switch (state)
            count++;
        }
    }
967295
func ValidateCode(ctx context.Context, b Backend, address common.Address) (bool, error) {
	code, err := b.CodeAt(ctx, address, nil)
	if err != nil {
		return false, err
	}
	return bytes.Equal(code, common.FromHex(contract.ContractDeployedCode)), nil
}
796839
func Valid(json string) bool {
	_, ok := validpayload(stringBytes(json), 0)
	return ok
}
699279
func isutf8(buf []byte, blen int) int {
	if blen <= 2 {
		return 0
	}
	// invalid utf-8 code
	if buf[0] == byte(0xc0) || buf[0] == byte(0xc1) ||
		buf[0] == byte(0xfe) || buf[0] == byte(0xff) {
		return 0
	}

	var (
		i      int = 3
		maxlen int = 6
	)
	if blen < 6 {
		maxlen = blen
	}
	for ; i < maxlen; i++ {
		fb := utf8FirstByte[i]
		mk := utf8FirstMask[i]
		if buf[0]&mk == fb {
			res := true
			for j := 1; j <= i-1; j++ {
				b := buf[j]
				if b == byte(0xc0) || b == byte(0xc1) ||
					b == byte(0xfe) || b == byte(0xff) {
					return 0
				}
				if b&byte(0xc0) != 0x80 {
					res = false
					break
				}
			}
			if res {
				return i
			}
		}
	}
	return 0
}
515955
func (b *PCMBuffer) AsI8() (out []int8) {
	if b == nil {
		return nil
	}
	switch b.DataType {
	case DataTypeI8:
		return b.I8
	case DataTypeI16:
		out = make([]int8, len(b.I16))
		for i := 0; i < len(b.I16); i++ {
			out[i] = int8(b.I16[i])
		}
	case DataTypeI32:
		out = make([]int8, len(b.I32))
		for i := 0; i < len(b.I32); i++ {
			out[i] = int8(b.I32[i])
		}
	case DataTypeF32:
		out = make([]int8, len(b.F32))
		for i := 0; i < len(b.F32); i++ {
			out[i] = int8(b.F32[i])
		}
	case DataTypeF64:
		out = make([]int8, len(b.F64))
		for i := 0; i < len(b.F64); i++ {
			out[i] = int8(b.F64[i])
		}
	}
	return out
}
1317473
func isValidTtl(v string) (uint32, bool) {
	i, err := strconv.Atoi(v)
	if err != nil {
		return uint32(0), false
	}
	if i > 2147483647 {
		return uint32(0), false
	}
	if i < 0 {
		return uint32(0), false
	}
	return uint32(i), true
}
1067992
func validKey(key string) bool {
	// UUIDv4's are 36 chars (16 bytes not including dashes)
	if len(key) != 36 {
		return false
	}

	// 0 indexed dash positions
	dashPos := []int{8, 13, 18, 23}
	for i := 0; i < len(key); i++ {
		atDashPos := false
		for _, pos := range dashPos {
			if i == pos {
				atDashPos = true
				break
			}
		}

		if atDashPos == true {
			if key[i] != '-' {
				return false
			}
			// continue the loop if dash is found
			continue
		}

		// if not a dash, make sure char is a-f or 0-9
		// 48 == '0', 57 == '9', 97 == 'a', 102 == 'f'
		if key[i] < 48 || (key[i] > 57 && key[i] < 97) || key[i] > 102 {
			return false
		}
	}

	return true
}
70216
func ByteSwappedUnicode(swap bool) {
	val := 0
	if swap {
		val = 1
	}
	C.TTF_ByteSwappedUNICODE(C.int(val))
}
250934
func Unicode16ToUTF8(str string) string {
	i := 0
	if strings.Index(str, `\u`) > 0 {
		i = 1
	}
	strSlice := strings.Split(str, `\u`)
	last := len(strSlice) - 1
	if len(strSlice[last]) > 4 {
		strSlice = append(strSlice, string(strSlice[last][4:]))
		strSlice[last] = string(strSlice[last][:4])
	}
	for ; i <= last; i++ {
		if x, err := strconv.ParseInt(strSlice[i], 16, 32); err == nil {
			strSlice[i] = string(x)
		}
	}
	return strings.Join(strSlice, "")
}