【问题标题】:How to convert String with " character to URL如何将带有“字符的字符串转换为URL
【发布时间】:2016-12-18 06:04:41
【问题描述】:

如何将"fff\"fff"之类的字符串转换为URL? URL 必须包含 " 字符并且类似于 "ff"ff"

【问题讨论】:

    标签: swift string url


    【解决方案1】:

    您将" 字符转义为%22。最简单的方法是通过URLComponents

    var components = URLComponents(string: "https://somewhere.com")!
    components.query = "ff\"ff"
    
    let url = components.url! // https://somewhere.com?ff%22ff
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-20
      • 2016-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-09
      相关资源
      最近更新 更多