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


Groups > comp.lang.python > #90313

Re: Why does unicode-escape decode escape symbols that are already escaped?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!feeder3.cambriumusenet.nl!82.197.223.107.MISMATCH!feeder1a.cambriumusenet.nl!82.197.223.103.MISMATCH!feeder3.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <somelauw@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'ascii': 0.09; 'literal': 0.09; 'strings.': 0.09; 'subject:Why': 0.09; 'to)': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; '2.7.2': 0.16; '4.9': 0.16; 'codecs': 0.16; 'subject:already': 0.16; 'subject:unicode': 0.16; 'syntaxerror:': 0.16; '>>>': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; '&gt;&gt;&gt;': 0.24; 'bytes': 0.24; 'unicode': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; '"",': 0.31; 'subject:that': 0.31; 'file': 0.32; 'linux': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'hi,': 0.36; 'skip:& 10': 0.38; 'nov': 0.38; 'skip:& 20': 0.39; 'skip:u 10': 0.60; 'more': 0.64; 'to:addr:yahoo.com': 0.81; '2014,': 0.84; '2013,': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=d9+RP9Z0dYbp69xKVUO0CtJaw7yQJXWL7tXbYjPE0Zc=; b=oqEKe7o4i/U09e1wVBwvOGPq/RZv27UVSnYLYZTtwae1KdzF+vfLkso9Z7VsCVFwCH v7PruoX/f4ZIgVjWOQvse/IJN8Olw5FvCntBJAHA77FC0gmNhw8Ho0dle0X2Sxu0G2/h JqT7Tmwr1VVQRbttZJ3jHoF0HPIEd+NqN/HIuGPPA6lEF/B098Y3RrPh4MEfys/YyAox XHGcxN0sJ4BP9ly1coV94d3x7J01uZhAoQMe7SeXVEIKdIuwhR+TVy3mpOix7Q0viM9r pX/tU+2gke8JaKGteCgBGD7YTlLncDTJIV7hU6A+wI7FnHxTO2Yxqr6cCtNaA9UjgYmy 4GFQ==
MIME-Version 1.0
X-Received by 10.55.21.211 with SMTP id 80mr16767608qkv.100.1431301534895; Sun, 10 May 2015 16:45:34 -0700 (PDT)
In-Reply-To <1431283174.10170.BPMail_high_carrier@web163801.mail.gq1.yahoo.com>
References <1431283174.10170.BPMail_high_carrier@web163801.mail.gq1.yahoo.com>
Date Mon, 11 May 2015 01:45:34 +0200
Subject Re: Why does unicode-escape decode escape symbols that are already escaped?
From "Somelauw ." <somelauw@gmail.com>
To Albert-Jan Roskam <fomcl@yahoo.com>
Cc python-list@python.org
Content-Type multipart/alternative; boundary=001a11473dce8dd3880515c2db36
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.327.1431301543.12865.python-list@python.org> (permalink)
Lines 74
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1431301543 news.xs4all.nl 2906 [2001:888:2000:d::a6]:39887
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:90313

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

2015-05-10 20:39 GMT+02:00 Albert-Jan Roskam <fomcl@yahoo.com>:

>
> Hi,
>
> I only have Python 2 on my phone, but I am suprised that you (and are able
> to) decode unicode strings. What result do you get when you do the
> following in Python 3:
>
> Python 2.7.2 (default, Oct 25 2014, 20:52:15)
> [GCC 4.9 20140827 (prerelease)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import codecs
> >>> codecs.decode(b'€', 'unicode-escape')
> u'\xe2\x82\xac'
> >>> codecs.encode(u'€', 'unicode-escape')
> '\\xe2\\x82\\xac'
> >>>
>
>
Python 3.3.3 (default, Nov 27 2013, 17:12:35)
[GCC 4.8.2] on linux
>>> import codecs
>>> codecs.decode(b'€', 'unicode-escape')
  File "<stdin>", line 1
SyntaxError: bytes can only contain ASCII literal characters.
>>> codecs.encode(u'€', 'unicode-escape')
b'\\u20ac'

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


Thread

Re: Why does unicode-escape decode escape symbols that are already escaped? "Somelauw ." <somelauw@gmail.com> - 2015-05-11 01:45 +0200

csiph-web