title: How to encode ''+' character in url string?
body: <p>I want to encode the <strong><code>+</code></strong> character in my url string, I tried to do that this way:</p>
  
  <pre><code>let urlString = "www.google.com?type=c++"
  
  let result = string.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
  </code></pre>
  
  <p>but this won't work for <strong><code>+</code></strong>.</p>
  
  <p>any idea? Thanks.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>What's more this <code>type=</code> parameter in the url is dynamic, I wouldn't do some implicite replacement on the <strong><code>+</code></strong>  character. This <code>type=</code> parameter represents a UITextField value, so there can be typed-in anything.</p>
  
  <p>I'm also curious why <code>addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)</code> won't work in this particular case?</p>