如何发送&符号在xml身体到服务器 [英] how to Send & symbol in xml body to server

查看:127
本文介绍了如何发送&符号在xml身体到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将& 符号发送到XML主体中的服务器,但只收到一个空白。
我试着用HTML代码发送这个,但徒劳无功。 你不能直接发送...少数实现如下:

  @implementation NSString(URLEncoding)

- (NSString *)stringByUrlEncoding {
return(NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)self,NULL,(CFStringRef)@!*'();:@& ;; = + $, /?%#[],kCFStringEncodingUTF8));
}

@end


I am trying to send the & symbol to the server in an XML body but only received a blank. I tried HTML code to send this also but in vain.

解决方案

You can create a category on NSString and then encode few characters that you cant send directly... few are implemented below:

@implementation NSString (URLEncoding)

- (NSString *) stringByUrlEncoding{
    return (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,  (CFStringRef)self,  NULL,  (CFStringRef)@"!*'();:@&;=+$,/?%#[]",  kCFStringEncodingUTF8));
}

@end

这篇关于如何发送&符号在xml身体到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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