Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98986

Re: handling of non-ASCII filenames?

From Christian Gollwitzer <auriocus@gmx.de>
Newsgroups comp.lang.python
Subject Re: handling of non-ASCII filenames?
Date 2015-11-18 18:22 +0100
Organization A noiseless patient Spider
Message-ID <n2ibvh$5th$1@dont-email.me> (permalink)
References <n2i9vt$icf$1@news2.informatik.uni-stuttgart.de>

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

handling of non-ASCII filenames? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 16:45 +0000
  Re: handling of non-ASCII filenames? Chris Angelico <rosuav@gmail.com> - 2015-11-19 03:54 +1100
    Re: handling of non-ASCII filenames? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 18:09 +0000
      Re: handling of non-ASCII filenames? Chris Angelico <rosuav@gmail.com> - 2015-11-19 07:29 +1100
        Re: handling of non-ASCII filenames? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-18 22:37 +0000
  Re: handling of non-ASCII filenames? Christian Gollwitzer <auriocus@gmx.de> - 2015-11-18 18:22 +0100
    Re: handling of non-ASCII filenames? Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2015-11-19 07:54 +0000
      Re: handling of non-ASCII filenames? Christian Gollwitzer <auriocus@gmx.de> - 2015-11-19 09:16 +0100

csiph-web