西班牙语字符编码 - iphone [英] Spanish character encoding - iphone

查看:1000
本文介绍了西班牙语字符编码 - iphone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从iphone发送文本到服务器进行处理。
该文本包含一些西班牙文字符,例如,áéíóúüñ¿ªªªªªªªººººººººº>>>>>>>>>>>>>>>,,,,,,,,,,,b服务器端也使用UTF8编码进行解码。



但服务器端将其解码为



请让我知道有没有人遇到这个问题,如何解决?



谢谢。

解决方案

我找到了解决方案。



由于这是一个帖子数据,我不得不转义特殊字符。 >

stringByAddingPercentEscapesUsingEncoding:似乎没有转义所有的特殊字符。我遇到这个问题,+字符被一个空格取代。



我觉得同样的事情发生在西班牙语字符,它没有正确逃脱,所以我手动替换它,它的工作。



以下是一个例子。我为所有角色写了这个字符

  escapedString = [escapedString stringByReplacingOccurrencesOfString:@ÀwithString:@%C0]; 
escapedString = [escapedString stringByReplacingOccurrencesOfString:@ÁwithString:@%C1];
escapedString = [escapedString stringByReplacingOccurrencesOfString:@ÂwithString:@%C2];
escapedString = [escapedString stringByReplacingOccurrencesOfString:@ÃwithString:@%C3];
escapedString = [escapedString stringByReplacingOccurrencesOfString:@ÄwithString:@%C4];

谢谢xj1200和saadnib查看这个。我真的很感激。如果你们找到其他更好的解决方案请发贴。


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.

解决方案

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

escapedString = [escapedString stringByReplacingOccurrencesOfString:@"À" withString:@"%C0"];        
        escapedString = [escapedString stringByReplacingOccurrencesOfString:@"Á" withString:@"%C1"];        
        escapedString = [escapedString stringByReplacingOccurrencesOfString:@"Â" withString:@"%C2"];        
        escapedString = [escapedString stringByReplacingOccurrencesOfString:@"Ã" withString:@"%C3"];        
        escapedString = [escapedString stringByReplacingOccurrencesOfString:@"Ä" withString:@"%C4"];

Thank you xj1200 and saadnib for looking in to this. I really appreciate. If you guys find any other better solution please post.

这篇关于西班牙语字符编码 - iphone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆