Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A test application exploring your options to replace stringByAddingPercentEscapesUsingEncoding when it can't cover all cases

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 StringEscapeTest.xcodeproj
Octocat-spinner-32 StringEscapeTest
Octocat-spinner-32 .gitignore
Octocat-spinner-32 readme.md
readme.md

What?

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.

Which methods?

  1. stringByAddingPercentEscapesUsingEncoding with UTF8 and ASCII encoding. (So you can see if they will work for your application)
  2. stringByReplacingPercentEscapesUsingEncoding with UTF8. (Just so I could see what it did)
  3. CFURLCreateStringByAddingPercentEscapes with various options.
  4. (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(…)) which casts CFURLCreateStringByAddingPercentEscapes into an NSString(This is my new preferred method for URLs that can have strange characters. It is very easy to configure as necessary)
  5. A large manual method from the Apple Developer Forums that uses a long set of stringByAddingPercentEscapesUsingEncoding statements to cover most cases. This is also very easy to configure and reuse as needed.
Something went wrong with that request. Please try again.