當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


GO QuoteToGraphic用法及代碼示例

GO語言"strconv"包中"QuoteToGraphic"函數的用法及代碼示例。

用法:

func QuoteToGraphic(s string) string

QuoteToGraphic 返回表示 s 的雙引號 Go 字符串文字。返回的字符串保留由 IsGraphic 定義的 Unicode 圖形字符不變,並對非圖形字符使用 Go 轉義序列(\t、\n、\xFF、\u0100)。

例子:

package main

import (
	"fmt"
	"strconv"
)

func main() {
	s := strconv.QuoteToGraphic("☺")
	fmt.Println(s)

	// This string literal contains a tab character.
	s = strconv.QuoteToGraphic("This is a \u263a	\u000a")
	fmt.Println(s)

	s = strconv.QuoteToGraphic(`" This is a ☺ \n "`)
	fmt.Println(s)

}

輸出:

"☺"
"This is a ☺\t\n"
"\" This is a ☺ \\n \""

相關用法


注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 QuoteToGraphic。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。