golang如何将中文转成GB2312值

jeanson-JinSheng · · 1870 次点击
https://github.com/djimenez/iconv-go 这玩意? 但凡会百度都能搜出来
#1
更多评论
``` package main import ( "fmt" "github.com/gogf/gf/v2/encoding/gcharset" ) func main() { str, err := gcharset.UTF8To("GBK", "我很好") if err != nil { panic(err) } bytes := []byte(str) fmt.Printf("0x%X", bytes[0]) for _, b := range bytes[1:] { fmt.Printf(",0x%X", b) } } ```
#2