Swift URL中的波斯语字符(带Alamofire)

Swift URL中的波斯语字符(带Alamofire),swift,post,request,alamofire,Swift,Post,Request,Alamofire,我有变量,我想把它们放在url中发布 某些变量可以是波斯语或英语字符 当角色是英语时,一切都很好 但当我使用波斯语字符时,alamofire响应无效url 代码是 让标题:字典=[ “内容类型”:“应用程序/json” ]; let request=Product_Rename()。 request.newName=string request.productId=UInt(\u Data[deletIndex].productId!) Alamofire.request(“http://exa

我有变量,我想把它们放在url中发布
某些变量可以是波斯语或英语字符
当角色是英语时,一切都很好 但当我使用波斯语字符时,alamofire响应无效url
代码是

让标题:字典=[ “内容类型”:“应用程序/json” ];
let request=Product_Rename()。 request.newName=string

request.productId=UInt(\u Data[deletIndex].productId!)
Alamofire.request(“http://example.com/api/product/rename?productId=\(\u Data[deletIndex].ProductId!)&newName=\(字符串)&AUTHID=\(AUTHID!)”,
方法:。将,
标题:标题)

.validate(状态代码:200..您必须从URL中转义特殊字符

request.productId = UInt(_Data[deletIndex].ProductId!)
let url = "http://example.com/api/product/rename?productId=\(_Data[deletIndex].ProductId!)&newName=\(string)&AUTHID=\(authID!)"
if let encodedUrl = original.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed) {
    Alamofire.request(encodedUrl,
    method: .put,
    headers: headers)
    .validate(statusCode: 200..<300)
    .responseString(completionHandler: {response in

    })
    // use the data
}
request.productId=UInt(\u Data[deletIndex].productId!)
让url=”http://example.com/api/product/rename?productId=\(\u Data[deletIndex].ProductId!)&newName=\(字符串)&AUTHID=\(AUTHID!))
如果let encodedUrl=original.addingPercentEncoding(允许使用以下字符:.urlFragmentAllowed){
Alamofire.请求(encodedUrl,
方法:。将,
标题:标题)

.validate(状态代码:200..您必须从URL中转义特殊字符

request.productId = UInt(_Data[deletIndex].ProductId!)
let url = "http://example.com/api/product/rename?productId=\(_Data[deletIndex].ProductId!)&newName=\(string)&AUTHID=\(authID!)"
if let encodedUrl = original.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed) {
    Alamofire.request(encodedUrl,
    method: .put,
    headers: headers)
    .validate(statusCode: 200..<300)
    .responseString(completionHandler: {response in

    })
    // use the data
}
request.productId=UInt(\u Data[deletIndex].productId!)
让url=”http://example.com/api/product/rename?productId=\(\u Data[deletIndex].ProductId!)&newName=\(字符串)&AUTHID=\(AUTHID!))
如果let encodedUrl=original.addingPercentEncoding(允许使用以下字符:.urlFragmentAllowed){
Alamofire.请求(encodedUrl,
方法:。将,
标题:标题)
.验证(状态代码:200。。