// StringToInt16 convert string to int16
181787
func StringToInt16(from string) (int16, error) {
	val, err := strconv.ParseInt(from, DefeultNumericBase, 16)
	return int16(val), err
}
675909
func ConvertToInt(target string, def int) int {
	fo, err := strconv.Atoi(target)
	if err != nil {
		return def
	}
	return fo
}
67311
func Int32ToString(from int32) (string, error) {
	return strconv.FormatInt(int64(from), DefeultNumericBase), nil
}
1110763
func SliceStringToInt(strings []string) ([]int, error) {
	ints := []int{}
	for _, s := range strings {
		thisInt, err := strconv.Atoi(s)
		if err != nil {
			return ints, err
		}
		ints = append(ints, thisInt)
	}
	return ints, nil
}
52493
func ipStringToInt(ipnr string) int64 {
	bits := strings.Split(ipnr, ".")
	if len(bits) != 4 {
		return -1
	}

	b0, _ := strconv.Atoi(bits[0])
	b1, _ := strconv.Atoi(bits[1])
	b2, _ := strconv.Atoi(bits[2])
	b3, _ := strconv.Atoi(bits[3])

	var sum int64

	sum += int64(b0) << 24
	sum += int64(b1) << 16
	sum += int64(b2) << 8
	sum += int64(b3)

	return sum
}
272314
func (be *BinaryEncoder) WriteInt16(value int16) {
	binary.BigEndian.PutUint16(be.buffer[be.pos:], uint16(value))
	be.pos += 2
}
547925
func (e *Event) Uint16(key string, i uint16) *Event {
	if e == nil {
		return e
	}
	e.buf = enc.AppendUint16(enc.AppendKey(e.buf, key), i)
	return e
}
1130362
func SliceStringToIntSort(strings []string) ([]int, error) {
	ints, err := SliceStringToInt(strings)
	if err != nil {
		return ints, err
	}
	intSlice := sort.IntSlice(ints)
	intSlice.Sort()
	return intSlice, nil
}
178057
func (dec *Decoder) Int16Null(v **int16) error {
	err := dec.decodeInt16Null(v)
	if err != nil {
		return err
	}
	dec.called |= 1
	return nil
}
1269941
func stringToUtf16Ptr(s string) unsafe.Pointer {
	tmp := utf16.Encode([]rune(s + "\000"))
	return unsafe.Pointer(&tmp[0])
}
529140
func StringToUint32(from string) (uint32, error) {
	val, err := strconv.ParseUint(from, DefeultNumericBase, 32)
	return uint32(val), err
}
992286
func (m *Manager) GetInt16(key string) int16 {
	return cast.ToInt16(m.Get(key))
}
1087869
func _putStr16(in string, out []byte) int {
	binary.BigEndian.PutUint16(out, uint16(len(in)))
	return copy(out[2:], in) + 2
}
832690
func TryToUint16(i interface{}) (r uint16, err error) {
	switch t := i.(type) {
	case nil:
		r = 0
	case uint:
		r = uint16(t)
	case uint8:
		r = uint16(t)
	case uint16:
		r = t
	case *uint16:
		r = *t
	case uint32:
		r = uint16(t)
	case uint64:
		r = uint16(t)
	case int:
		r = uint16(t)
	case int8:
		r = uint16(t)
	case int16:
		r = uint16(t)
	case int32:
		r = uint16(t)
	case int64:
		r = uint16(t)
	case float32:
		r = uint16(t)
	case float64:
		r = uint16(t)
	case bool:
		if t {
			r = 1
		}
	case string:
		var v uint64
		if v, err = strconv.ParseUint(t, 10, 16); err == nil {
			r = uint16(v)
		}
	default:
		err = castError(i, "uint16")
	}
	return
}
938502
func (e Encoder) AppendInt16(dst []byte, val int16) []byte {
	return e.AppendInt(dst, int(val))
}
94239
func (vb *keyWriter) WriteUint16(num uint16) (int, error) {
	binary.BigEndian.PutUint16(vb.buffer[:2], num)
	vb.hash.Write(vb.buffer[:2])
	return 2, nil
}
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)
}