dongzouhe9734 2017-10-25 02:57
浏览 17
已采纳

在Go中解码URL

I am calling an API that is returning a URL in a UTF-8 encoded XML document. The parsing is returning something like http://www.test.com and I want to convert it to 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/

    for _, user := range x.Users {
        a := strings.Replace(user.Username, ":", ":", -1)
        b := strings.Replace(a, "/", "/", -1)
        fmt.Println(b)
    }
  • 写回答

1条回答 默认 最新

  • dqef7931 2017-10-25 05:18
    关注

    Just call html.UnescapeString("http://www.test.com") which results in http://www.test.com.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 非root手机,如何精准控制手机流量消耗的大小,如20M
  • ¥15 远程安装一下vasp
  • ¥15 自己做的代码上传图片时,报错
  • ¥15 Lingo线性规划模型怎么搭建
  • ¥15 关于#python#的问题,请各位专家解答!区间型正向化
  • ¥15 unity从3D升级到urp管线,打包ab包后,材质全部变紫色
  • ¥50 comsol温度场仿真无法模拟微米级激光光斑
  • ¥15 上传图片时提交的存储类型
  • ¥15 VB.NET如何绘制倾斜的椭圆
  • ¥15 arbotix没有/cmd_vel话题