Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #90299
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'encoded': 0.07; 'python3': 0.07; 'string': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Why': 0.09; 'python': 0.11; 'bug': 0.12; 'jan': 0.12; 'codecs': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject: \n ': 0.16; 'subject:already': 0.16; 'subject:unicode': 0.16; 'exception': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; 'this?': 0.23; 'header:User-Agent:1': 0.23; 'instead.': 0.24; 'this:': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'raise': 0.29; "doesn't": 0.30; "skip:' 10": 0.31; 'agreed.': 0.31; 'subject:that': 0.31; 'linux': 0.33; 'sense': 0.34; 'doing': 0.36; 'subject:?': 0.36; 'should': 0.36; 'nov': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'received:fios.verizon.net': 0.84; '\xe2\x82\xac': 0.84; '2013,': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: Why does unicode-escape decode escape symbols that are already escaped? |
| Date | Sun, 10 May 2015 13:00:52 -0400 |
| References | <CA+gt_a82WGXHUZhcdbTUWG+TRV1Ys1ZSrkGjOxgavZGjAh9FiQ@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | quoted-printable |
| X-Gmane-NNTP-Posting-Host | pool-98-114-97-173.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
| In-Reply-To | <CA+gt_a82WGXHUZhcdbTUWG+TRV1Ys1ZSrkGjOxgavZGjAh9FiQ@mail.gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.319.1431277269.12865.python-list@python.org> (permalink) |
| Lines | 26 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1431277269 news.xs4all.nl 2872 [2001:888:2000:d::a6]:34127 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:90299 |
Show key headers only | View raw
On 5/10/2015 11:53 AM, Somelauw . wrote:
> In Python 3, decoding "€" with unicode-escape returns 'â\x82¬' which in
> my opinion doesn't make sense.
Agreed. I think this is a bug in that it should raise an exception
instead. Decoding a string only makes sense for rot-13
> The € already is decoded; if it were encoded it would look like this:
> '\u20ac'.
> So why is it doing this?
> $ python3 -S
> Python 3.3.3 (default, Nov 27 2013, 17:12:35)
> [GCC 4.8.2] on linux
> >>> import codecs
> >>> codecs.decode('€', 'unicode-escape')
> 'â\x82¬'
> >>> codecs.encode('€', 'unicode-escape')
> b'\\u20ac'
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Why does unicode-escape decode escape symbols that are already escaped? Terry Reedy <tjreedy@udel.edu> - 2015-05-10 13:00 -0400 Re: Why does unicode-escape decode escape symbols that are already escaped? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-11 14:00 +1000
csiph-web