Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strike>NSString's <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/stringByAddingPercentEscapesUsingEncoding:" rel="noreferrer">stringByAddingPercentEscapesUsingEncoding:</a> looks like what you're after.</strike></p> <p><strong>EDIT</strong>: Here's an example using <a href="http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFURLRef/Reference/reference.html#//apple_ref/c/func/CFURLCreateStringByAddingPercentEscapes" rel="noreferrer"><code>CFURLCreateStringByAddingPercentEscapes</code></a> instead. <code>originalString</code> can be either an <code>NSString</code> or a <code>CFStringRef</code>. </p> <pre><code>CFStringRef newString = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, originalString, NULL, CFSTR("!*'();:@&amp;=+@,/?#[]"), kCFStringEncodingUTF8); </code></pre> <p>Please note that this is untested. You should have a look at the <a href="http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFURLRef/Reference/reference.html#//apple_ref/c/func/CFURLCreateStringByAddingPercentEscapes" rel="noreferrer">documentation page</a> to make sure you understand the memory allocation semantics for <code>CFStringRef</code>, the idea of toll-free bridging, and so on.</p> <p>Also, I don't know (off the top of my head) which of the characters specified in the <code>legalURLCharactersToBeEscaped</code> argument would have been escaped anyway (due to being illegal in URLs). You may want to check this, although it's perhaps better just to be on the safe side and directly specify the characters you want escaped.</p> <p>I'm making this answer a community wiki so that people with more knowledge about CoreFoundation can make improvements.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload