简体   繁体   English

NSString应要求将@转换为%40

[英]NSString Converting @ to %40 on Request

Currently I'm using Resty (http://projects.lukeredpath.co.uk/resty/) to build my own API wrapper for Objective-C. 目前,我正在使用Resty(http://projects.lukeredpath.co.uk/resty/)为Objective-C构建自己的API包装器。

I digress however, in the request itself, I am able to determine what is actually being sent and it seems that the NSString *email (I scan for an @ to make sure it is a legitimate email before storing in another NSString) is actually changed. 但是,我离题了,在请求本身中,我能够确定实际发送的内容,似乎NSString * email(在存储在另一个NSString中之前,我扫描了@以确保它是合法电子邮件)实际上已更改。

An example, joe@example.com has been scanned for the @, and then sent to the NSString *email for the request. 例如,已扫描joe@example.com中的@,然后将其发送到NSString * email以获取请求。 However, when I send the actual GET request, the NSString is changed to joe%40example.com. 但是,当我发送实际的GET请求时,NSString更改为joe%40example.com。

Is this due to the Resty request, or do I have to encode/decode the NSString before the request? 这是由于Resty请求造成的,还是我必须在请求之前对NSString进行编码/解码?

Yes, you should URL decode and then perform any validation tasks. 是的,您应该URL解码,然后执行任何验证任务。

Here is what their documentation has: 他们的文档如下:

NSData or any other data-encodable payloads set the request body as-is; NSData或任何其他可编码数据的有效负载将请求主体保持原样; encodable payloads will be encoded using UTF8 可编码有效载荷将使用UTF8进行编码

http://projects.lukeredpath.co.uk/resty/documentation.html http://projects.lukeredpath.co.uk/resty/documentation.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM