// BstrToString converts COM binary string to Go string.
505558
func BstrToString(p *uint16) string {
	if p == nil {
		return ""
	}
	length := SysStringLen((*int16)(unsafe.Pointer(p)))
	a := make([]uint16, length)

	ptr := unsafe.Pointer(p)

	for i := 0; i < int(length); i++ {
		a[i] = *(*uint16)(ptr)
		ptr = unsafe.Pointer(uintptr(ptr) + 2)
	}
	return string(utf16.Decode(a))
}
336486
func (b *Bytes) WriteString(str string) (int, error) {
	return b.Write([]byte(str))
}
1259017
func readString(rd *bufio.Reader) (string, error) {
	// Read string length.
	var sLen int32
	if err := binary.Read(rd, binary.LittleEndian, &sLen); err != nil {
		return "", err
	}
	if sLen == 0 {
		return "", nil
	}

	// Read string.
	b := make([]byte, sLen)
	if _, err := io.ReadFull(rd, b); err != nil {
		return "", err
	}
	return string(b[:len(b)-1]), nil
}
511276
func toString(v reflect.Value) (string, error) {
	switch v.Kind() {
	case reflect.String:
		return v.String(), nil
	case reflect.Interface:
		return toString(v.Elem())
	}
	return "", errors.New("unable to convert value to string")
}
1252937
func (t *Taint) ToString() string {
	if len(t.Value) == 0 {
		return fmt.Sprintf("%v:%v", t.Key, t.Effect)
	}
	return fmt.Sprintf("%v=%v:%v", t.Key, t.Value, t.Effect)
}
1088999
func (b Bit) ToString() string {
	byteSize := (b.Width + 7) / 8
	buf := make([]byte, byteSize)
	for i := byteSize - 1; i >= 0; i-- {
		buf[byteSize-i-1] = byte(b.Value >> uint(i*8))
	}
	return string(buf)
}
101205
func ReaderToString(lines io.Reader) string {
	if lines == nil {
		return ""
	}
	b := bp.GetBuffer()
	defer bp.PutBuffer(b)
	b.ReadFrom(lines)
	return b.String()
}
283134
func ConvertToString(b []byte) string {
	s := make([]string, len(b))
	for i := range b {
		s[i] = strconv.Itoa(int(b[i]))
	}
	return strings.Join(s, ",")
}
1225638
func toString(v reflect.Value) string {
	if v.Kind() == reflect.Interface && !v.IsNil() {
		v = v.Elem()
	}
	if v.Kind() == reflect.Ptr {
		v = v.Elem()
	}
	if v.Kind() == reflect.String {
		return v.String()
	}
	return fmt.Sprint(v.Interface())
}
231208
func fmtString(validAbbr map[string]string, validKeys []string) string {
	var sb strings.Builder
	i := 0
	for k, v := range validAbbr {
		sb.WriteString(fmt.Sprintf("%s(%s) ", v, k))
		i++
		if i != len(validAbbr) {
			sb.WriteString(",")
		}
	}
	if len(sb.String()) == 0 {
		for _, k := range validKeys {
			sb.WriteString(fmt.Sprintf("%s ", k))
		}
	}
	return sb.String()
}
874577
func (e *Encoding) EncodeToString(src []byte) string {
	dst := make([]byte, EncodedLen(len(src)))
	e.Encode(dst, src)
	return string(dst)
}
394828
func StringOrBytes(value interface{}) (isString bool, str string, isBytes bool, bs []byte) {
	v := reflect.ValueOf(value)
	if v.Kind() == reflect.String {
		str = v.String()
		isString = true
	} else if v.Kind() == reflect.Slice && v.Type() == bytesType {
		bs = v.Interface().([]byte)
		isBytes = true
	}
	return
}
990514
func (be *BinaryEncoder) WriteString(x string) {
	be.WriteLong(int64(len(x)))
	_, _ = be.buffer.Write([]byte(x))
}
218574
func MsgsToString(msgs []Msg, lineSep, linePrefix string) string {
	linePrefixRest := lineSep + linePrefix

	var buf bytes.Buffer

	for i := range msgs {
		msg := &msgs[i]

		body := ""
		bodySep := ""
		if msg.Body != nil {
			body = string(msg.Body)
			bodySep = " "
		}

		linePrefixCur := ""
		if i > 0 {
			linePrefixCur = linePrefixRest
		}

		if msg.Repeats > 1 {
			fmt.Fprintf(&buf, "%s%s (%dx)%s%s",
				linePrefixCur, msg.Title, msg.Repeats, bodySep, body)
		} else {
			fmt.Fprintf(&buf, "%s%s%s%s",
				linePrefixCur, msg.Title, bodySep, body)
		}
	}

	return buf.String()
}
722489
func LpOleStrToString(p *uint16) string {
	if p == nil {
		return ""
	}

	length := lpOleStrLen(p)
	a := make([]uint16, length)

	ptr := unsafe.Pointer(p)

	for i := 0; i < int(length); i++ {
		a[i] = *(*uint16)(ptr)
		ptr = unsafe.Pointer(uintptr(ptr) + 2)
	}

	return string(utf16.Decode(a))
}
886187
func uintptrCFStringToString(s uintptr) string {
	p := C.CFStringGetCStringPtrSafe(C.uintptr_t(s), C.kCFStringEncodingUTF8)
	if p != nil {
		return C.GoString(p)
	}
	length := C.CFStringGetLengthSafe(C.uintptr_t(s))
	if length == 0 {
		return ""
	}
	maxBufLen := C.CFStringGetMaximumSizeForEncoding(length, C.kCFStringEncodingUTF8)
	if maxBufLen == 0 {
		return ""
	}
	buf := make([]byte, maxBufLen)
	var usedBufLen C.CFIndex
	_ = C.CFStringGetBytesSafe(C.uintptr_t(s), C.CFRange{0, length}, C.kCFStringEncodingUTF8, C.UInt8(0), C.false, (*C.UInt8)(&buf[0]), maxBufLen, &usedBufLen)
	return string(buf[:usedBufLen])
}
11992
func (s Serializers) SerializeToString(key string, obj interface{}, options ...map[string]interface{}) (string, error) {
	result, err := s.Serialize(key, obj, options...)
	if err != nil {
		return "", err
	}

	return string(result), nil
}