简单的字符串编码可以使用下面方式
str := "aabb,&8?%s" ret := url.QueryEscape(str) log.Println(ret) encodedValue := "Hell%C3%B6+W%C3%B6rld%40Golang" decodedValue, err := url.QueryUnescape(encodedValue) log.Println(decodedValue, err)
输出结果
2021/08/14 11:35:12 aabb%2C%268%3F%25s 2021/08/14 11:35:13 Hell? W?rld@Golang <nil>