This is a small sample project that shows the output caused by different string escaping methods. If you've ever worked with encoding strings through Objective-C you probably know that
stringByAddingPercentEscapesUsingEncoding doesn't work for all characters. This project shows you the output from different methods to replace this.
stringByAddingPercentEscapesUsingEncodingwith UTF8 and ASCII encoding. (So you can see if they will work for your application)
stringByReplacingPercentEscapesUsingEncodingwith UTF8. (Just so I could see what it did)
CFURLCreateStringByAddingPercentEscapeswith various options.
(NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(…))which casts
NSString(This is my new preferred method for URLs that can have strange characters. It is very easy to configure as necessary)
- A large manual method from the Apple Developer Forums that uses a long set of
stringByAddingPercentEscapesUsingEncodingstatements to cover most cases. This is also very easy to configure and reuse as needed.