2

Me need so that Alamofire send utf-8 parameters to my server, now he transmits English characters normally, but Russian characters as hieroglyphs. After checking the encoding I found that it is 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 your help. Thanks you.

Wolfak
  • 97
  • 1
  • 2
  • 9

1 Answers1

8

Swift 3

let newStr = String(utf8String: stringToDecode.cString(using: .utf8)!)

Source StackOverFlow

Abdul Waheed
  • 863
  • 8
  • 14