发送post方法后,单词之间的空格会丢失

时间:2016-03-02 06:09:35

标签: swift post nsurlsession

我试图发布订单但是在代码之下删除了单词之间的空格。

例如,它发布到网络端" StreetDistrictEtc"如果customer_address是" Street District Etc"

我想知道可能的原因是什么?因为CFStringConvertEncodingToNSStringEncoding还是Web服务端的东西?

    let form1 = "user_id=\(self.order.user_id)&product_id=\(self.order.order_id)&order_no=\(self.order.order_no)&customer_addres=\(self.order.customer_address)"

    let myUrl = NSURL(string: "http://webservis.mydomain.com/order_post.asp")
    let request = NSMutableURLRequest(URL:myUrl!)
    request.HTTPMethod = "POST"

    let cfEnc = CFStringEncodings.ISOLatin5
    let enc = CFStringConvertEncodingToNSStringEncoding(CFStringEncoding(cfEnc.rawValue))
    request.HTTPBody = form1.dataUsingEncoding(enc)

0 个答案:

没有答案