UTF8 Character in URL String
<p>I wrote a little Python script that parses a website.
I got a "Ã¤" character in form of <code>\u00e4</code> in a url from a link like <code>http://foo.com/h\u00e4ppo</code>, and I need <code>http://foo.com/hÃ¤ppo</code>.</p>

<p>The character <code>\u00e4</code> which you have is already correct. That is in fact <code>Ã¤</code>.</p>

<p>Sometimes, the representation (<code>repr</code>) of a string will display it in the escaped form, just as backslash <code>\</code> will be display as escaped <code>\\</code>. That part is fine.</p>

<h2>The Actual Problem</h2>

<p>The actual problem is that you cannot use Ã¤ in URL. Only a small subset o ASCII characters is valid in URLS (see <a href="http://stackoverflow.com/q/1547899/389289">Which characters make a URL invalid?</a>).</p>

<p>So, you have to escape parts of your URL.</p>

<pre><code>&gt;&gt;&gt; urllib.parse.quote('Ã¤')
'%C3%A4'

&gt;&gt;&gt; urllib.parse.quote('\u00e4')  # same thing
'%C3%A4'
</code></pre>

<p>But be careful not to escape the whole URL, only parts of it which are actual strings to be escaped. For example, this is wrong:</p>

<pre><code>&gt;&gt;&gt; urllib.parse.quote('https://www.google.com/?q=\u00e4')
'https%3A//www.google.com/%3Fq%3D%C3%A4'
</code></pre>

<p>You'll want to do:</p>

<pre><code>&gt;&gt;&gt; 'https://www.google.com/?q=' + urllib.parse.quote('\u00e4')
'https://www.google.com/?q=%C3%A4'
</code></pre>

<p>Try it and see what happens: <a href="https://www.google.com/?q=%C3%A4" rel="nofollow">https://www.google.com/?q=%C3%A4</a></p>

python url encoding