GO語言"mime"包中"WordEncoder.Encode"類型的用法及代碼示例。
用法:
func(e WordEncoder) Encode(charset, s string) string
編碼返回 s 的 encoded-word 形式。如果 s 是沒有特殊字符的 ASCII,則原樣返回。提供的字符集是 s 的 IANA 字符集名稱。它不區分大小寫。
例子:
package main
import (
"fmt"
"mime"
)
func main() {
fmt.Println(mime.QEncoding.Encode("utf-8", "¡Hola, señor!"))
fmt.Println(mime.QEncoding.Encode("utf-8", "Hello!"))
fmt.Println(mime.BEncoding.Encode("UTF-8", "¡Hola, señor!"))
fmt.Println(mime.QEncoding.Encode("ISO-8859-1", "Caf\xE9"))
}
輸出:
=?utf-8?q?=C2=A1Hola,_se=C3=B1or!?= Hello! =?UTF-8?b?wqFIb2xhLCBzZcOxb3Ih?= =?ISO-8859-1?q?Caf=E9?=
相關用法
- GO WordDecoder.Decode用法及代碼示例
- GO WordDecoder.DecodeHeader用法及代碼示例
- GO WithDeadline用法及代碼示例
- GO Writer.Init用法及代碼示例
- GO WaitGroup用法及代碼示例
- GO Writer.WriteAll用法及代碼示例
- GO WriteFile用法及代碼示例
- GO Writer.RegisterCompressor用法及代碼示例
- GO WithValue用法及代碼示例
- GO WalkDir用法及代碼示例
- GO WithTimeout用法及代碼示例
- GO Writer用法及代碼示例
- GO WriteString用法及代碼示例
- GO Write用法及代碼示例
- GO WithCancel用法及代碼示例
- GO Writer.AvailableBuffer用法及代碼示例
- GO Walk用法及代碼示例
- GO PutUvarint用法及代碼示例
- GO Scanner.Scan用法及代碼示例
- GO LeadingZeros32用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 WordEncoder.Encode。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。