I want to represent all characters in a string as in this table.
But when I do
raw = 'æøå'
encoded = raw.encode('cp1252')
print(encoded)
I get
>>> b'\xe6\xf8\xe5'
What I want is
>>> %E6%F8%E5
as a string for use in a URL.
I want to represent all characters in a string as in this table.
But when I do
raw = 'æøå'
encoded = raw.encode('cp1252')
print(encoded)
I get
>>> b'\xe6\xf8\xe5'
What I want is
>>> %E6%F8%E5
as a string for use in a URL.
You have to "quote" your string using urllib tools.
import urllib.parse
raw = 'æøå'
print(urllib.parse.quote(raw, encoding='cp1252'))
# returns "%E6%F8%E5"