本文整理匯總了Golang中strconv.AppendQuoteRuneToASCII函數的典型用法代碼示例。如果您正苦於以下問題:Golang AppendQuoteRuneToASCII函數的具體用法?Golang AppendQuoteRuneToASCII怎麽用?Golang AppendQuoteRuneToASCII使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AppendQuoteRuneToASCII函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ExampleAppendQuoteRuneToASCII
func ExampleAppendQuoteRuneToASCII() {
b := []byte("rune (ascii):")
b = strconv.AppendQuoteRuneToASCII(b, '☺')
fmt.Println(string(b))
// Output:
// rune (ascii):'\u263a'
}
示例2: fmt_qc
// 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)
}
示例3: fmt_qc
// 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))
}
}
示例4: main
func main() {
b := []byte("rune (ascii):")
b = strconv.AppendQuoteRuneToASCII(b, '☺')
fmt.Println(string(b))
}