[英]How to achieve URL encoding in iphone?
I am developing an application in which I need to encode URL. 我正在开发一个需要对URL进行编码的应用程序。 I tried using http://simonwoodside.com/weblog/2009/4/22/how_to_really_url_encode/ and
[NSString stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]
but its not working out for me. 我尝试使用http://simonwoodside.com/weblog/2009/4/22/how_to_really_url_encode/和
[NSString stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]
但对我来说不起作用。 Is there any alternate URL encoder class for iphone like java? 是否有iphone之类的其他备用URL编码器类,例如java? How to achieve it??
如何实现呢? Thanks in advance...
提前致谢...
尝试以下方法进行URL编码:
NSString *url= [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)originalpath, NULL, CFSTR(";:"), kCFStringEncodingUTF8) autorelease];
您可以尝试以下方法进行URL编码:
`NSString *urlString = [NSString stringWithFormat:@"http://www.abc.com/parsexml.aspx?query=%@", [searchBar.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];`
您可以参考这篇文章找到您的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.