Question about character of NSString invalid in URL on iPhone

流过昼夜 提交于 2019-12-01 06:03:01

I think this is a better approach:

NSString* escapedUrl = [originalUrl   
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

If you want to understand how URL encoding works, take a look at this URL.

See RFC 2396 for the full gory details. The following characters must be escaped:

Control characters (ASCII 00-1F and 7F)
Space
<
>
#
%
"

The following characters are unwise to use without escaping because some gateways and other transport agents are known to sometimes modify such characters, or they are used as delimiters:

{ } | \ ^ [ ] `

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!