title: How to encode an url
body: <pre><code>NSString* urlEncode(NSString * url)
  {
      string inStr = StringFromNSString(url);
      CFStringRef inStringRef = CFStringCreateWithCString( kCFAllocatorDefault, inStr.c_str(), kCFStringEncodingUTF8 );
      NSString * encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)inStringRef,NULL,(CFStringRef)@"!*’();:@&amp;=+$,/?%#[]",kCFStringEncodingUTF8 );
      return encodedString;
  }
  </code></pre>
  
  <p>I am using above method to encode url... even though my app is crashing saying </p>
  
  <pre><code>&lt;body&gt;
      &lt;div id="content"&gt;
          &lt;h1&gt;An Error Was Encountered&lt;/h1&gt;
          &lt;p&gt;The URI you submitted has disallowed characters.&lt;/p&gt; &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  terminate called after throwing an instance of 'std::invalid_argument'
    what(): 
  </code></pre>
  
  <p>Any idea.. What is wrong with my code?</p>
  
  <p>FYI: It is crashing in this method JSONNode jsonObject0 = libJSON::parse( inResponseData );</p>
  
  <p>UPDATED: The server which i am sending message is UNIX server is it causing problem?</p>