How convert string to utf-8? (Swift, Alamofire) -


me need alamofire send utf-8 parameters server, transmits english characters normally, russian characters hieroglyphs. after checking encoding found used maccyrillic characters.

let parameters: parameters = ["username": login.text!, "password": password.text!]

        alamofire.request("link ti site", method: .post, parameters: parameters).responsejson { response in              switch response.result {             case .success:                  let json = json(response.result.value)              case .failure( _):                  var errorstring = "null"                  if let data = response.data {                     if let json = try? jsonserialization.jsonobject(with: data, options: []) as! [string: string] {                         errorstring = json["error"]!                     }                 }              }          } 

need help. you.

swift 3

let newstr = string(utf8string: stringtodecode.cstring(using: .utf8)!) 

source stackoverflow


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -