func ExampleAppendQuoteRuneToASCII() { b := []byte("rune (ascii):") b = strconv.AppendQuoteRuneToASCII(b, '☺') fmt.Println(string(b)) // Output: // rune (ascii):'\u263a' }
// fmt_qc formats the integer as a single-quoted, escaped Go character constant. // If the character is not valid Unicode, it will print '\ufffd'. func (f *fmt) fmt_qc(c int64) { var quoted []byte if f.plus { quoted = strconv.AppendQuoteRuneToASCII(f.intbuf[0:0], rune(c)) } else { quoted = strconv.AppendQuoteRune(f.intbuf[0:0], rune(c)) } f.pad(quoted) }
// fmt_qc formats an integer as a single-quoted, escaped Go character constant. // If the character is not valid Unicode, it will print '\ufffd'. func (f *fmt) fmt_qc(c uint64) { r := rune(c) if c > utf8.MaxRune { r = utf8.RuneError } buf := f.intbuf[:0] if f.plus { f.pad(strconv.AppendQuoteRuneToASCII(buf, r)) } else { f.pad(strconv.AppendQuoteRune(buf, r)) } }
func main() { b := []byte("rune (ascii):") b = strconv.AppendQuoteRuneToASCII(b, '☺') fmt.Println(string(b)) }