values := url.Values{}
values.Add(“name”, “gopher”)
values.Add(“limit”, “20”)
str:=gurl.BuildQuery(values) //limit=20&name=gopher
fmt.Println(str)
encodeStr := gurl.Encode(str) //编码limit%3D20%26name%3Dgopher
fmt.Println(encodeStr)
decodeStr, _ := gurl.Decode(encodeStr) //解码limit=20&name=gopher
fmt.Println(decodeStr)
data, _ := gurl.ParseURL(“http://127.0.0.1:8199/goods?limit=20&name=gopher&page=7", -1)
fmt.Println(data)//解析map[fragment: host:127.0.0.1 pass: path:/goods port:8199 query:limit=20&name=gopher&page=7 scheme:http user:]
str, _ := gcharset.Convert("utf-8", "gb2312", src) //转换成utf8
str,_=gcharset.ToUTF8("gb2312",src) //utf8
str,_=gcharset.UTF8To("gb2312",str)//转换成gbk
作者:Yoby 创建时间:2021-11-02 01:49
更新时间:2024-12-05 13:26
更新时间:2024-12-05 13:26