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


Groups > comp.lang.python > #90313 > unrolled thread

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

Started by"Somelauw ." <somelauw@gmail.com>
First post2015-05-11 01:45 +0200
Last post2015-05-11 01:45 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

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

From"Somelauw ." <somelauw@gmail.com>
Date2015-05-11 01:45 +0200
SubjectRe: Why does unicode-escape decode escape symbols that are already escaped?
Message-ID<mailman.327.1431301543.12865.python-list@python.org>

[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'

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web