encoding url using swift code

后端 未结 6 1198
野性不改
野性不改 2021-02-12 21:03

I need to send an URL in Arabic language, so I need to encode it before I put it in URL. I am using Swift code.

Below is an example what i really need

va         


        
6条回答
  •  南笙
    南笙 (楼主)
    2021-02-12 21:40

    Swift 2.0

    let urlwithPercentEscapes = myurlstring.stringByAddingPercentEncodingWithAllowedCharacters( NSCharacterSet.URLQueryAllowedCharacterSet())
    

    Swift 3

    let urlwithPercentEscapes = myurlstring.addingPercentEncoding( withAllowedCharacters: .urlQueryAllowed)
    

提交回复
热议问题