title: AFNetworking: encoding URL strings containing '%'-sign fails
body: <p>I'm using <a href="https://github.com/AFNetworking/AFNetworking" rel="nofollow">AFNetworking</a> in my iOS App. I've discovered a problem that occurs when request parameters contain percent signs. Then the encoding fails. The method <code>AFURLEncodedStringFromStringWithEncoding</code> returns nil.</p>
  
  <p>I've tested this code and it prints <code>(null)</code>:</p>
  
  <pre><code>NSLog(@"%@", AFURLEncodedStringFromStringWithEncoding(@"%", NSUTF8StringEncoding));
  </code></pre>
  
  <p>The expected output should be: <code>%25</code>. Other characters can be encoded with no problem.</p>
  
  <p>The method is defined as follows:</p>
  
  <pre><code>NSString * AFURLEncodedStringFromStringWithEncoding(NSString *string, NSStringEncoding encoding) {
      static NSString * const kAFLegalCharactersToBeEscaped = @"?!@#$^&amp;%*+,:;='\"`&lt;&gt;()[]{}/\\|~ ";
  
      // Following the suggestion in documentation for `CFURLCreateStringByAddingPercentEscapes` to "pre-process" URL strings (using stringByReplacingPercentEscapesUsingEncoding) with unpredictable sequences that may already contain percent escapes.
      return [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)[string stringByReplacingPercentEscapesUsingEncoding:encoding], NULL, (CFStringRef)kAFLegalCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(encoding)) autorelease];
  }
  </code></pre>
  
  <p>Any ideas what's going wrong here?</p>
  
  <p><strong>EDIT:</strong> <a href="https://github.com/AFNetworking/AFNetworking/issues/209" rel="nofollow">The issue has been fixed in AFNetworking</a>. </p>