Go语言中文网 为您找到相关结果 3

[golang]一个复杂的中文编码问题

今天在网上遇到一个问题,觉得挺有意思,就帮人解答了。 需求 在编码为Latin1的MySQL数据库中插入中文数据,由另一个系统将Latin1编码的字符串转码为GBK后作为短信内容发出。 简单版解答 import ( "golang.org/x/text/encoding/charmap" "golang.org/x/text/encoding/simplifiedchinese" ) func Convert(src string) (string, error) { gbk, err := simplifiedchinese.GBK.NewEncoder().Bytes([]byte(src)) if err != nil { return "", err } latin1, err :=...阅读全文

博文 2017-09-16 03:04:56 一桶冷水

golang 阿里云发送短信接口

1.阿里云发短信 //SendMsg 发送短信 func SendMsg(phone, msgJSON string) bool { body := "send msg" content := url.QueryEscape(msgJSON) signString := setQueryStr(phone, content, "13223334554545") singstr := signLinaJie + url.QueryEscape(signString) sign := hmac4Go(singstr, sk+lianJIe) client := &http.Client{} var req *http.Request req, err = http.NewRequest("GET...阅读全文

博文 2018-08-09 18:35:05 Aaronjqw