Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'encoding': 0.05; 'represents': 0.05; 'binary': 0.07; 'utf-8': 0.07; "'a'": 0.09; 'ascii': 0.09; 'bytes.': 0.09; 'character,': 0.09; 'explanation': 0.09; 'methods,': 0.09; 'url:unicode': 0.09; "'b'": 0.16; 'andreas': 0.16; 'bye,': 0.16; 'charset': 0.16; 'ebcdic': 0.16; 'format?': 0.16; 'hexadecimal': 0.16; 's[0]': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'byte': 0.24; 'bytes': 0.24; 'case.': 0.24; 'integer': 0.24; 'unicode': 0.24; 'why.': 0.24; 'decide': 0.24; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'work.': 0.31; '>>>>': 0.31; 'decimal': 0.31; 'stands': 0.31; 'terms.': 0.31; 'url:python': 0.33; 'subject:from': 0.34; 'could': 0.34; 'subject: (': 0.35; 'no,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'format.': 0.36; 'right?': 0.36; 'sequence': 0.36; 'method': 0.36; 'possible': 0.36; 'url:org': 0.36; 'should': 0.36; 'received:10': 0.37; 'represent': 0.38; 'message-id:@gmail.com': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'url:3': 0.61; 'first': 0.61; 'here': 0.66; 'dont': 0.67; 'yes': 0.68; 'containing': 0.69; '8bit%:100': 0.72; 'sets,': 0.84; 'url:reference': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=WH8rkvmRzT9Z0IVMXLzj1nbOhv+XK1N+tawqqxlWGZU=; b=ItWAuN6vc0r1fXkqAGI8OyEVz9p1bs/v6NOH9uJVEW16pc/KZcbl7La2UF3glnY1QP pfp+/1AXwTO2Zu5LHqwxJGv6T/Hv2Nryj3Q0zODhqSSuOoyuR6V24/Zl1/P4UQg0iATS P8qSliMesBArg2ZsHC842dp1Z1sQMvENBw0u/Oa4eWhHSS0BxoJZ6iGYJUfCfeb0qkIg OOKxQAEBOzJkKnrY/Ks7RLG7iF2qu52gROSbO0sm5FFAoFq7ftAmpITXZm+Rb3Urvb9f 9qGHkgjwJ1yDlwEEqXS/eK0bQ5OkdasDhuQC1lKttY9N6BHLQPnpltYNPity8+4kuXGL un4w== X-Received: by 10.204.234.9 with SMTP id ka9mr689754bkb.22.1370860947736; Mon, 10 Jun 2013 03:42:27 -0700 (PDT) Date: Mon, 10 Jun 2013 12:42:25 +0200 From: Andreas Perstinger User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Changing filenames from Greeklish => Greek (subprocess complain) References: <7d8da6c9-fb92-4329-b207-4280f29ba664@googlegroups.com> <20130608024931.GA77888@cskk.homeip.net> <51B37173.9060601@gmail.com> <3fbb5d0e-51fb-4aed-b829-8388304a9885@googlegroups.com> <51b4249d$0$30001$c3e8da3$5496439d@news.astraweb.com> <5b0d3d7c-e3a4-436d-a55f-26bd40064fd5@googlegroups.com> <51b475b0$0$30001$c3e8da3$5496439d@news.astraweb.com> <349f7474-fce3-4891-8eb2-92fc53606fb2@googlegroups.com> In-Reply-To: <349f7474-fce3-4891-8eb2-92fc53606fb2@googlegroups.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 57 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370860953 news.xs4all.nl 15923 [2001:888:2000:d::a6]:49677 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47545 On 10.06.2013 11:59, Νικόλαος Κούρας wrote: >> >>>> s = 'α' >> >>>> s.encode('utf-8') >> > b'\xce\xb1' > > 'b' stands for binary right? No, here it stands for bytes: http://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals > b'\xce\xb1' = we are looking at a byte in a hexadecimal format? No, b'\xce\xb1' represents a byte object containing 2 bytes. Yes, each byte is represented in hexadecimal format. > if yes how could we see it in binary and decimal represenation? >>> s = b'\xce\xb1' >>> s[0] 206 >>> bin(s[0]) '0b11001110' >>> s[1] 177 >>> bin(s[1]) '0b10110001' A byte object is a sequence of bytes (= integer values) and support indexing. http://docs.python.org/3/library/stdtypes.html#bytes > Since 2^8 = 256, utf-8 should store the first 256 chars of unicode > charset using 1 byte. > > Also Since 2^16 = 65535, utf-8 should store the first 65535 chars of > unicode charset using 2 bytes and so on. > > But i know that this is not the case. But i dont understand why. Because your method doesn't work. If you use all possible 256 bit-combinations to represent a valid character, how do you decide where to stop in a sequence of bytes? >> >>>> s = 'a' >> >>>> s.encode('utf-8') >> > b'a' >> utf-8 takes ASCII as it is, as 1 byte. They are the same > > EBCDIC and ASCII and Unicode are charactet sets, correct? > > iso-8859-1, iso-8859-7, utf-8, utf-16, utf-32 and so on are encoding methods, right? > Look at http://www.unicode.org/glossary/ for an explanation of all the terms. Bye, Andreas