title: addingPercentEncoding works different in Swift
body: <p>I have obj-C method that encodes String:</p>
  
  <pre><code>- (NSString *) encodeValue:(NSString*) unescaped{
      return [unescaped stringByAddingPercentEncodingWithAllowedCharacters:
               [NSCharacterSet URLHostAllowedCharacterSet]];
  }
  </code></pre>
  
  <p>input: <code>testswiftapppod://</code></p>
  
  <p>output: <code>testswiftapppod%3A%2F%2F</code></p>
  
  <p>I wrote the same method in Swift but got different output: <code>testswiftapppod:%2F%2F</code></p>
  
  <pre><code>static func encodeValue(unescaped:String!) -&gt; String{
     return unescaped.addingPercentEncoding(
          withAllowedCharacters: CharacterSet.urlHostAllowed)!
  }
  </code></pre>
  
  <p><strong>For some reason colon not converted</strong></p>
  
  <p>How to fix this issue? </p>
  
  <p>I use Xcode 8.3</p>
  
  <p><strong>[EDIT]</strong></p>
  
  <p>From Docs:</p>
  
  <blockquote>
    <p>// Returns a new string made from the receiver by replacing all
    characters not in the allowedCharacters set with percent encoded
    characters. UTF-8 encoding is used to determine the correct percent
    encoded characters. Entire URL strings cannot be percent-encoded. This
    method is intended to percent-encode an URL component or subcomponent
    string, NOT the entire URL string. Any characters in allowedCharacters
    outside of the 7-bit ASCII range are ignored.
    - (nullable NSString *)stringByAddingPercentEncodingWithAllowedCharacters:(NSCharacterSet *)allowedCharacters NS_AVAILABLE(10_9, 7_0);</p>
  </blockquote>