问题
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.
回答1:
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
回答2:
You can use the HTML entity:
&
For a full list of the HTML character entities see this.
来源:https://stackoverflow.com/questions/20094023/how-to-send-symbol-in-xml-body-to-server