handling of non-ASCII filenames?
Christian Gollwitzer
auriocus at gmx.de
Wed Nov 18 12:22:05 EST 2015
Am 18.11.15 um 17:45 schrieb Ulli Horlacher:
> This is my encoding function:
>
> def url_encode(s):
> u = ''
> for c in list(s):
> if match(r'[_=:,;<>()+.\w\-]',c):
> u += c
> else:
> u += '%' + c.encode("hex").upper()
> return u
>
>
The quoting is applied to a UTF8 string. But I think you shouldn't do it
yourself, use a library function:
import urllib
urllib.quote(yourstring.encode('utf8'))
Christian
More information about the Python-list
mailing list