前端之家收集整理的这篇文章主要介绍了
swift 之 URL编码,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
func encodeEscapesURL(value:String) -> String {
let str:NSString = value
let originalString = str as CFStringRef
let charactersToBeEscaped = "!*'();:@&=+$,/?%#[]" as CFStringRef
let result =
CFURLCreateStringByAddingPercentEscapes(kcfAllocatorDefault,originalString,nil,
charactersToBeEscaped,CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)) as NSString
return result as String
}
原文链接:https://www.f2er.com/swift/326733.html