// WriteRune appends the UTF-8 encoding of Unicode code point r to b's buffer.
// It returns the length of r and a nil error.
341530
func (b *StringBuilder) WriteRune(r rune) (int, error) {
	b.copyCheck()
	if r < utf8.RuneSelf {
		b.buf = append(b.buf, byte(r))
		return 1, nil
	}
	l := len(b.buf)
	if cap(b.buf)-l < utf8.UTFMax {
		b.grow(utf8.UTFMax)
	}
	n := utf8.EncodeRune(b.buf[l:l+utf8.UTFMax], r)
	b.buf = b.buf[:l+n]
	return n, nil
}
1198206
func (b *Uint64) UnmarshalText(input []byte) error {
	raw, err := checkNumberText(input)
	if err != nil {
		return err
	}
	if len(raw) > 16 {
		return ErrUint64Range
	}
	var dec uint64
	for _, byte := range raw {
		nib := decodeNibble(byte)
		if nib == badNibble {
			return ErrSyntax
		}
		dec *= 16
		dec += nib
	}
	*b = Uint64(dec)
	return nil
}
459068
func (r *copyReader) init() {
	_, r.rerr = r.WriteTo(&r.rbuf)
}
667381
func (file *File) Writen(buf []byte, offset uint64) (int, error) {
	ret := 0
	for len(buf) > 0 {
		n, err := file.WriteAt(buf, int64(offset))
		if err != nil {
			return ret, err
		}

		if n == 0 {
			break
		}

		buf = buf[n:]
		offset += uint64(n)
		ret += n
	}

	return ret, nil
}
1080972
func FnBase64(name string, input interface{}, template interface{}) interface{} {

	// { "Fn::Base64" : valueToEncode }

	// Check the input is a string
	if src, ok := input.(string); ok {
		return base64.StdEncoding.EncodeToString([]byte(src))
	}

	return nil

}
206540
func NewWriter(charset string, w io.Writer) (io.WriteCloser, error) {
	tr, err := TranslatorTo(charset)
	if err != nil {
		return nil, err
	}
	return NewTranslatingWriter(w, tr), nil
}
972422
func (b *ByteBuf) WriteInt(v int) (n int, err error) {
	b.Expansion(4)
	Int2BytesTo(v, b.buf[b.writerIndex:b.writerIndex+4])
	b.writerIndex += 4
	return 4, nil
}
1338279
func WriteUint(u uint64, buffer *WriterAsBuffer) {
	var a [64 + 1]byte
	i := len(a)

	if ^uintptr(0)>>32 == 0 {
		for u > uint64(^uintptr(0)) {
			q := u / 1e9
			us := uintptr(u - q*1e9)
			for j := 9; j > 0; j-- {
				i--
				qs := us / 10
				a[i] = byte(us - qs*10 + '0')
				us = qs
			}
			u = q
		}
	}

	us := uintptr(u)
	for us >= 10 {
		i--
		q := us / 10
		a[i] = byte(us - q*10 + '0')
		us = q
	}

	i--
	a[i] = byte(us + '0')
	buffer.Write(a[i:])
}
413919
func writeRaw(w *textWriter, b []byte) error {
	if err := w.WriteByte('<'); err != nil {
		return err
	}
	if !w.compact {
		if err := w.WriteByte('\n'); err != nil {
			return err
		}
	}
	w.indent()
	if err := writeUnknownStruct(w, b); err != nil {
		return err
	}
	w.unindent()
	if err := w.WriteByte('>'); err != nil {
		return err
	}
	return nil
}
1162530
func writeAny(w io.Writer, html bool, x interface{}) {
	switch v := x.(type) {
	case []byte:
		writeText(w, v, html)
	case string:
		writeText(w, []byte(v), html)
	default:
		if html {
			var buf bytes.Buffer
			fmt.Fprint(&buf, x)
			writeText(w, buf.Bytes(), true)
		} else {
			fmt.Fprint(w, x)
		}
	}
}
673082
func (se *SizingEncoder) WriteString(value string) {
	se.WriteInt16(int16(len(value)))
	se.size += len(value)
}
587899
func WriteArbitraryAsString(w io.Writer, m interface{}) error {
	buf := AppendArbitraryAsStrings(make([]byte, 0, 1024), m)
	_, err := w.Write(buf)
	return err
}
480300
func (Encoder) AppendInt(dst []byte, val int) []byte {
	return strconv.AppendInt(dst, int64(val), 10)
}
795283
func WriteRune(x int, y int, r rune, fg termbox.Attribute, bg termbox.Attribute) {
	termbox.SetCell(x, y, r, fg, bg)
}
1201622
func (b *ByteBuffer) WriteRune(r rune) (int, error) {
	b.Lock()
	defer b.Unlock()
	return b.b.WriteRune(r)
}
110071
func (nvt *NameValueType) Pprint(depth int) string {
	output := bytes.Buffer{}
	output.WriteString(strings.Repeat("\u00a0", depth*2))
	output.WriteString(fmt.Sprintf("%s [%s]: ", nvt.Name, nvt.Typ))
	if nvts, ok := nvt.Value.([]*NameValueType); ok {
		output.WriteString("\n")
		for _, next := range nvts {
			sublevel := next.Pprint(depth + 1)
			output.WriteString(sublevel)
		}
	} else {
		output.WriteString(fmt.Sprintf("%q\n", nvt.Value))
	}
	return output.String()
}
480339
func (enc *Encoder) WriteInt(n int) error {
	return enc.writeUnsigned((n << 1) ^ (n >> 31))
}