【发布时间】:2016-12-18 06:04:41
【问题描述】:
如何将"fff\"fff"之类的字符串转换为URL? URL 必须包含 " 字符并且类似于 "ff"ff"
【问题讨论】:
如何将"fff\"fff"之类的字符串转换为URL? URL 必须包含 " 字符并且类似于 "ff"ff"
【问题讨论】:
您将" 字符转义为%22。最简单的方法是通过URLComponents:
var components = URLComponents(string: "https://somewhere.com")!
components.query = "ff\"ff"
let url = components.url! // https://somewhere.com?ff%22ff
【讨论】: