Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You must not percent encode the <em>whole</em> string. Instead, only the <em>data octet</em> in a component must be possibly encoded.</p> <p>In other words, a URI consists of components and subcomponents which are delimited by certain characters. These characters are called "reserved characters". The separators for the different components must certainly not be included in the percent encoding. </p> <p>Note that each component of a URL may require a slightly different percent encoding.</p> <p>See also <a href="https://tools.ietf.org/html/rfc3986" rel="nofollow">RFC 3986</a>.</p> <hr> <h3>Edit:</h3> <p>The general structure of a URL is given below:</p> <pre><code> URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] </code></pre> <p>The following two examples are straight copied from RFC which show their component parts:</p> <pre><code> foo://example.com:8042/over/there?name=ferret#nose \_/ \______________/\_________/ \_________/ \__/ | | | | | scheme authority path query fragment | _____________________|__ / \ / \ urn:example:animal:ferret:nose </code></pre> <p>The "query component" consists of a list of "key/value" parameters whose key and value is separated by "=", and whose parameters are separated by "&amp;".</p> <p>The query component is everything after the question mark <code>'?'</code> up until a hash character <code>'#'</code>.</p> <p>The following code <em>encodes</em> the <em>name</em> or the <em>value</em> of a parameter. Note that parameters must be separated by a '&amp;', and the name and value must be separated by a '='.</p> <pre><code>static NSString* form_urlencode_rfc3986(NSString* s) { CFStringRef charactersToLeaveUnescaped = CFSTR(" "); //CFStringRef legalURLCharactersToBeEscaped = CFSTR("!$&amp;'()+,/:;=?@~"); // Modified for urls (excluding '~'): CFStringRef legalURLCharactersToBeEscaped = CFSTR("!$&amp;'()+,/:;=?@"); NSString *result = CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes( kCFAllocatorDefault, (__bridge CFStringRef)s, charactersToLeaveUnescaped, legalURLCharactersToBeEscaped, kCFStringEncodingUTF8)); return [result stringByReplacingOccurrencesOfString:@" " withString:@"+"]; } </code></pre>
 

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