[英]Decoding URL in Go
I am calling an API that is returning a URL in a UTF-8 encoded XML document.我正在调用一个 API,它返回一个 UTF-8 编码的 XML 文档中的 URL。 The parsing is returning something like
http://www.test.com
and I want to convert it to http://www.test.com
.解析返回类似
http://www.test.com
,我想将其转换为http://www.test.com
。
I'm struggling to find the right way to do this.我正在努力寻找正确的方法来做到这一点。 Any help would be appreciated!
任何帮助,将不胜感激!
Edit: this code does what I need, but would have thought there would have been a pre-built function that does something similar to this website: https://www.url-encode-decode.com/编辑:这段代码可以满足我的需要,但我会认为会有一个预建的函数可以做类似于这个网站的事情: https : //www.url-encode-decode.com/
for _, user := range x.Users {
a := strings.Replace(user.Username, ":", ":", -1)
b := strings.Replace(a, "/", "/", -1)
fmt.Println(b)
}
只需调用html.UnescapeString("http://www.test.com")
得到http://www.test.com
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.