swift - Can't convert string to UTF-8 with Alamofire -


i have api want use alamofire library, need use utf-8 make api url support spaces , arabic. have tried these 2 ways no success.

let d = "ddd dd" let f = string(d.utf8)! let bb = string(utf8string: f.cstringusingencoding(nsutf8stringencoding)!)! let encodedname = d.stringbyaddingpercentescapesusingencoding(nsutf8stringencoding) 

these lines wrong:

let f = string(d.utf8)! let bb = string(utf8string: f.cstringusingencoding(nsutf8stringencoding)!)! 

you not need or want c string. , not need convert utf8; swift string unicode. , every time use exclamation mark (!) saying "please crash me" - cannot surprised when in fact crash.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -