encoding url using swift code

后端 未结 6 1191
野性不改
野性不改 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:32

    swift 4 we face the same problem it solved by this way

    extension String { 
    var fixedArabicURL: String?  {
           return self.addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics
               .union(CharacterSet.urlPathAllowed)
               .union(CharacterSet.urlHostAllowed))
       } }
    

提交回复
热议问题