西班牙语字符编码 - iphone
我正在将文本从 iphone 发送到服务器进行处理。 文本包含一些西班牙语字符,例如 á é í ó ú ü ñ ¿ ¡ ºª
发送时,我使用 NSUTF8StringEncoding 对其进行编码 服务器端也是使用UTF8编码来解码。
但服务器端将其解码为??????
请告诉我是否有人遇到过这个问题以及如何解决的?
谢谢。
I am sending text from iphone to the server for processing.
The text contain some spanish characters eg, á é í ó ú ü ñ ¿ ¡ ºª
While sending, I am encoding it with NSUTF8StringEncoding
Server side is also using UTF8 encoding to decode it.
But the server side decodes it as ???????
Please let me know if anyone has faced this issue and how this was resolved ?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了解决方案。
由于这是一个帖子数据,我必须转义特殊字符。
stringByAddingPercentEscapesUsingEncoding:
似乎没有转义所有特殊字符。我遇到了“+”字符的问题,它被空格替换了。我觉得西班牙字符也会发生同样的情况,它没有正确转义,所以我手动替换了它并且它起作用了。
下面是一个例子。我为所有角色写了这篇文章,
谢谢 xj1200 和 saadnib 的关注。我真的很感激。如果你们发现任何其他更好的解决方案,请发布。
I found the solution.
Since this is a post data I had to escape the special characters.
stringByAddingPercentEscapesUsingEncoding:
doesn't seem to escape all the special characters. I faced this issue with "+" character where it was getting replaced by a whitespace.I feel same thing happens with spanish character where it is not escaped properly, so I manually replaced it and it worked.
following is an example. I wrote this for all the characters
Thank you xj1200 and saadnib for looking in to this. I really appreciate. If you guys find any other better solution please post.
我认为您可以使用 Google Toolbox for Mac 对这些字符进行编码。查看文件 GTMNSString+
http ://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/?r=27#trunk%2FFoundation
I think you can use Google Toolbox for Mac for ancoding these characters. See files GTMNSString+
http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/?r=27#trunk%2FFoundation