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


Groups > comp.lang.python > #99037

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-19 09:16 +0100
Organization A noiseless patient Spider
Message-ID <n2k0c3$cjn$2@dont-email.me> (permalink)
References <n2i9vt$icf$1@news2.informatik.uni-stuttgart.de> <n2ibvh$5th$1@dont-email.me> <n2jv7k$14p$2@news2.informatik.uni-stuttgart.de>

Show all headers | View raw


Am 19.11.15 um 08:54 schrieb Ulli Horlacher:
> Christian Gollwitzer <auriocus@gmx.de> wrote:
>> 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.
>
> encode("hex") works only with binary strings?
> How do I convert a UTF8 string to binary?

It's right in the other line I showed you:

Apfelkiste:Tests chris$ python
Python 2.7.2 (default, Oct 11 2012, 20:14:37)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> u"blablüa".encode('utf8')
'blabl\xc3\xbca'
 >>>

	Christian

Back to comp.lang.python | Previous | NextPrevious 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