Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99037
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Christian Gollwitzer <auriocus@gmx.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: handling of non-ASCII filenames? |
| Date | Thu, 19 Nov 2015 09:16:15 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 32 |
| 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> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-15; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Thu, 19 Nov 2015 08:13:55 -0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="09360e0ab07672f4bcf79b9f96c5414e"; logging-data="12919"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18uc+A0D+lMCUYdpu7X7O9hXfnQtQB1CkI=" |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
| In-Reply-To | <n2jv7k$14p$2@news2.informatik.uni-stuttgart.de> |
| Cancel-Lock | sha1:LSiLFDMjZBmOUoO7iRkT8qdXkc4= |
| Xref | csiph.com comp.lang.python:99037 |
Show key headers only | 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 | Next — Previous in thread | Find similar | Unroll 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