var str = "Hello, playground+" var allowCharactoers = CharacterSet.urlQueryAllowed allowCharactoers.remove(Unicode.Scalar("+")) print(str.addingPercentEncoding(withAllowedCharacters: allowCharactoers))
輸出: Optional("Hello,%20playground%2B")
參考資料:
https://stackoverflow.com/questions/31577188/how-to-encode-into-2b-with-nsurlcomponents
全站熱搜
留言列表