我正在使用
Alamofire.request(.GET, "http://")
.responseString { _, _, string, _ in
println(string)
}
进行获取请求。响应包含西里尔字符,在 responseString 中它们看起来像这样(右上角):
我应该如何修复编码?
最佳答案
您可以将 NSUTF8StringEncoding
与 Alamofire 的 responseString
方法一起使用:
Alamofire.request(.GET, "http://my1test.ru/applejesus.php?task=getCategory&categoryNumber=1")
.responseString(encoding: NSUTF8StringEncoding) { (request, response, string, error) -> Void in
if let result = string {
println(result)
}
}
结果:
picture{http://ipic.su/img/img7/fs/ProdukciyaApple.1438079721.png},title{Продукция Apple}
关于swift - Alamofire 返回错误的编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31733254/