// writeCstring writes BSON cstring. This is not a BSON element.
13490
func writeCstring(buf *bytes.Buffer, s string) error {
	if _, err := buf.WriteString(s); err != nil {
		return err
	}
	return buf.WriteByte(0x00)
}
396332
func (b *StringBuilder) Write(p []byte) (int, error) {
	b.copyCheck()
	b.buf = append(b.buf, p...)
	return len(p), nil
}
430206
func (l *LogFile) WriteString(s string) (int, error) {
	l.Lock()
	defer l.Unlock()
	return l.writer.Write([]byte(s))
}
737382
func (u *UI) ColorString(c Color, s string) string {
	if !u.EnableColors {
		return s
	}

	ctx := ansiterm.Context{
		Foreground: ansiterm.Color(c),
	}

	return createStyledString(ctx, s)
}
662505
func encodeString(buf *bytes.Buffer, name string, val String) error {
	// type
	if err := buf.WriteByte(_STRING); err != nil {
		return err
	}

	// name
	if err := writeCstring(buf, name); err != nil {
		return err
	}

	// value
	return writeString(buf, string(val))
}
1260711
func CFStringToString(s C.CFStringRef) string {
	p := C.CFStringGetCStringPtr(s, C.kCFStringEncodingUTF8)
	if p != nil {
		return C.GoString(p)
	}
	length := C.CFStringGetLength(s)
	if length == 0 {
		return ""
	}
	maxBufLen := C.CFStringGetMaximumSizeForEncoding(length, C.kCFStringEncodingUTF8)
	if maxBufLen == 0 {
		return ""
	}
	buf := make([]byte, maxBufLen)
	var usedBufLen C.CFIndex
	_ = C.CFStringGetBytes(s, C.CFRange{0, length}, C.kCFStringEncodingUTF8, C.UInt8(0), C.false, (*C.UInt8)(&buf[0]), maxBufLen, &usedBufLen)
	return string(buf[:usedBufLen])
}
594258
func (r *csvreadwriter) write(s ...string) (string, error) {
	if len(s) == 0 {
		return "", nil
	}
	if len(s) == 1 {
		return s[0], nil
	}
	r.buf.Reset()
	if r.Writer == nil {
		w := csv.NewWriter(r.buf)
		w.Comma = r.sep
		r.Writer = w
	}
	if err := r.Writer.Write(s); err != nil {
		return "", err
	}
	r.Writer.Flush()

	bts := r.buf.Bytes()

	// Remove the trailing newline.
	return string(bts[:len(bts)-1]), nil
}
986742
func (w *Writer) WriteString(s string) (int, error) {
	c, l, ln := cap(w.buf), len(w.buf), len(s)
	avail := c - l

	// requires flush
	if avail < ln {
		if err := w.Flush(); err != nil {
			return 0, err
		}
		l = len(w.buf)
	}
	// too big to fit in buffer;
	// write directly to w.w
	//
	// yes, this is unsafe. *but*
	// io.Writer is not allowed
	// to mutate its input or
	// maintain a reference to it,
	// per the spec in package io.
	//
	// plus, if the string is really
	// too big to fit in the buffer, then
	// creating a copy to write it is
	// expensive (and, strictly speaking,
	// unnecessary)
	if c < ln {
		return w.w.Write(unsafestr(s))
	}

	// grow buf slice; copy; return
	w.buf = w.buf[:l+ln]
	return copy(w.buf[l:], s), nil
}
1197954
func (enc *Encoder) EncodeString(s string) error {
	if enc.isPooled == 1 {
		panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
	}
	_, _ = enc.encodeString(s)
	_, err := enc.Write()
	if err != nil {
		enc.err = err
		return err
	}
	return nil
}
803144
func WriteStringToFile(filename string, value string) error {
	//	fmt.Printf("writing %s to file %s\n", value, filename)
	f, e := os.OpenFile(filename, os.O_WRONLY|os.O_TRUNC, 0666)
	if e != nil {
		return e
	}
	defer f.Close()

	_, e = f.WriteString(value)
	return e
}
1026965
func copyCFString(cfs C.CFStringRef) C.CFStringRef {
	return C.CFStringCreateCopy(C.kCFAllocatorDefault, cfs)
}
322640
func (stream *Stream) WriteString(s string) {
	valLen := len(s)
	stream.buf = append(stream.buf, '"')
	// write string, the fast path, without utf8 and escape support
	i := 0
	for ; i < valLen; i++ {
		c := s[i]
		if c > 31 && c != '"' && c != '\\' {
			stream.buf = append(stream.buf, c)
		} else {
			break
		}
	}
	if i == valLen {
		stream.buf = append(stream.buf, '"')
		return
	}
	writeStringSlowPath(stream, i, s, valLen)
}
856498
func (b *Buffer) WriteString(s string) (n int, err error) {
	m := b.grow(len(s))
	return copy(b.buf[m:], s), nil
}
505148
func (b *StringBuilder) WriteString(s string) (int, error) {
	b.copyCheck()
	b.buf = append(b.buf, s...)
	return len(s), nil
}
67978
func readCstring(rd *bufio.Reader) (string, error) {
	s, err := rd.ReadString(0x00)
	if err != nil {
		return "", err
	}
	return s[:len(s)-1], nil
}
673082
func (se *SizingEncoder) WriteString(value string) {
	se.WriteInt16(int16(len(value)))
	se.size += len(value)
}
578700
func (b *ByteBuffer) WriteString(s string) (int, error) {
	b.Lock()
	defer b.Unlock()
	return b.b.WriteString(s)
}