Swift - encode URL

后端 未结 17 1874
無奈伤痛
無奈伤痛 2020-11-21 22:20

If I encode a string like this:

var escapedString = originalString.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)

it does

17条回答
  •  渐次进展
    2020-11-21 22:46

    Everything is same

    var str = CFURLCreateStringByAddingPercentEscapes(
        nil,
        "test/test",
        nil,
        "!*'();:@&=+$,/?%#[]",
        CFStringBuiltInEncodings.UTF8.rawValue
    )
    
    // test%2Ftest
    

提交回复
热议问题