}
func appendEscapedRune(buf []byte, r rune, quote byte, ASCIIonly, graphicOnly bool) []byte {
- var runeTmp [utf8.UTFMax]byte
if r == rune(quote) || r == '\\' { // always backslashed
buf = append(buf, '\\')
buf = append(buf, byte(r))
return buf
}
} else if IsPrint(r) || graphicOnly && isInGraphicList(r) {
- n := utf8.EncodeRune(runeTmp[:], r)
- buf = append(buf, runeTmp[:n]...)
- return buf
+ return utf8.AppendRune(buf, r)
}
switch r {
case '\a':
if r < utf8.RuneSelf || !multibyte {
buf = append(buf, byte(r))
} else {
- var arr [utf8.UTFMax]byte
- n := utf8.EncodeRune(arr[:], r)
- buf = append(buf, arr[:n]...)
+ buf = utf8.AppendRune(buf, r)
}
}