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
Post a Comment