When I type the text “gå” in a swedish web page, the html generates the following field: g%E5. That is, the letter a-ring (å) is coded as %E5. I assume that they are using ISO-8859-1.
If I generate the same html address using a Python 3.0 script the string “gå” is coded as g%C3%A5. Now the letter a-ring(å) is coded as %C3%A5. I assume that Python 3.0 (string)is using utf-8 to code the a-ring in this way.
How can I use Python 3 to generate the html address with g%E5?
I created this Python source file:
and got
as output.
I’m using Python 2, but it should be the same for Python 3 without the
ubefore the unicode literal, possibly without the coding line, and withasciiinstead ofrepr.So it should be as simple as specifying
"ISO-8859-1"as the encoding.Without seeing your exact code I can’t tell you where specifically to do that. Check out the docs for whatever you’re using for how to set the encoding.