Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'example:': 0.03; 'from:addr:yahoo.co.uk': 0.04; 'subject:text': 0.05; 'utf-8': 0.07; 'exception.': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:question': 0.10; 'python': 0.11; 'language.': 0.14; 'codec': 0.16; 'objects.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'language': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'byte': 0.24; 'bytes': 0.24; 'header:X-Complaints- To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'dec': 0.30; '"",': 0.31; 'file': 0.32; 'linux': 0.33; '(most': 0.33; "can't": 0.35; 'objects': 0.35; 'hat': 0.38; 'mapping': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'our': 0.64; 'more': 0.64; 'charset:windows-1252': 0.65; 'invalid': 0.68; '2014,': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Newbie question about text encoding Date: Sat, 07 Mar 2015 17:02:35 +0000 References: <9169f3b1-2ac7-42a3-8033-584f84b88a1f@googlegroups.com> <7a75a23c-4678-4d7a-a2ec-9e8fff4c07f8@googlegroups.com> <132d5ce6-f672-4eec-99f9-1cc9e88b94f3@googlegroups.com> <619e4cb5-1c4c-449b-a5d7-951101b32b45@googlegroups.com> <54f862ca$0$13014$c3e8da3$5496439d@news.astraweb.com> <54fadc70$0$13004$c3e8da3$5496439d@news.astraweb.com> <87twxxxbvd.fsf@elektro.pacujo.net> <54fb1bf4$0$12993$c3e8da3$5496439d@news.astraweb.com> <87twxw4xlz.fsf@elektro.pacujo.net> <87k2ysydtk.fsf@elektro.pacujo.net> <87fv9gycrr.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-78-147-191-2.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 In-Reply-To: <87fv9gycrr.fsf@elektro.pacujo.net> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1425747767 news.xs4all.nl 2976 [2001:888:2000:d::a6]:55085 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87111 On 07/03/2015 16:48, Marko Rauhamaa wrote: > Mark Lawrence : > >> On 07/03/2015 16:25, Marko Rauhamaa wrote: >>> Here's an example: >>> >>> b = b'\x80' >>> >>> Yes, it generates an exception. IOW, UTF-8 is not a bijective mapping >>> from str objects to bytes objects. >> >> Python 2 might, Python 3 doesn't. > > Python 3.3.2 (default, Dec 4 2014, 12:49:00) > [GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> b'\x80'.decode('utf-8') > Traceback (most recent call last): > File "", line 1, in > UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: > invalid start byte > > > Marko > It would clearly help if you were to type in the correct UK English accent. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence