Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'represents': 0.05; 'that?': 0.05; 'column': 0.07; 'subject:few': 0.09; 'cc:addr :python-list': 0.11; 'benjamin': 0.16; 'hex': 0.16; 'hexadecimal': 0.16; 'ordinal': 0.16; 'programmer,': 0.16; 'received:192.168.1.20': 0.16; '>>>': 0.22; 'cc:addr:python.org': 0.22; '>>>': 0.24; 'byte': 0.24; 'char': 0.24; "shouldn't": 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'gives': 0.31; 'decimal': 0.31; 'so-called': 0.31; 'open': 0.33; 'convert': 0.35; 'received:google.com': 0.35; 'sequence': 0.36; "didn't": 0.36; 'charset:us-ascii': 0.36; 'tell': 0.60; 'browser': 0.61; 'first': 0.61; 'header:Message-Id:1': 0.63; 'click': 0.77; 'to:addr:support': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schollnick.net; s=schollnick; h=sender:content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to:x-mailer; bh=mq4DbJZrs7Z9oXBAlKSiQy5XDACSmMkO+o68BiR3i7g=; b=nWbH4qldMmcSLLi6GBog1lV0cR215OK8LGRsjB2H8vByi9svlJOP0Xqro1MkFap8d2 Tx/j379zPUfT7etuW2YWmGy0ZMN5qMl9KcS8AKiUfK+2QFpOktT2WBPosHQ9RpAZbv1A ptgYDUb/keGn+uMQ0FbqPsyt8exL6J/r8luzE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to:x-mailer:x-gm-message-state; bh=mq4DbJZrs7Z9oXBAlKSiQy5XDACSmMkO+o68BiR3i7g=; b=mvnljpRmxRbt+gzb9qNmUZIdAKi2mxCCubwJJAQNxLfxWb8EFn8Vd5i47NjLSmeXIX qER7q7KEw164LR4vLCtrfV2UlU5PR3QjGXW3AvCQlyj8X5GY+E37chi1tQJh5uf5wyDo GiSGf/W0hV6v34baAysOtX4nX3wk5iyObpDxynkQi7t8YkOl8RMTmzzN7KljeO8HByGD RohdN+KLxVtQXjIjFt2EHhvO54/d68eUE+OhwNy+KRobfWv5jL7m0CwZUH45gMTn6pdz +MD3g9hrQQtV37+yZkAiNEpbS/nuD6WSXA3iLKy0vkYMoeaZk6vBI2UST9PGsDL4ptyt LspQ== X-Received: by 10.50.26.40 with SMTP id i8mr1745454igg.20.1371328551168; Sat, 15 Jun 2013 13:35:51 -0700 (PDT) Sender: Benjamin Schollnick Content-Type: multipart/alternative; boundary="Apple-Mail=_44315BAF-0C1C-4AF3-91CB-0F253D77F633" Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Subject: Re: A few questiosn about encoding From: Benjamin Schollnick In-Reply-To: Date: Sat, 15 Jun 2013 16:35:48 -0400 References: To: Nick the Gr33k X-Mailer: Apple Mail (2.1508) X-Gm-Message-State: ALoCoQlQhKoTPw3LthWDKXcoorrGUZE+K3QMw8e+iaLnHngtfV9BAUvKgGgQDXO3ZQKY7rdWw3y9 Cc: python-list@python.org 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: 80 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371328560 news.xs4all.nl 15873 [2001:888:2000:d::a6]:58322 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48366 --Apple-Mail=_44315BAF-0C1C-4AF3-91CB-0F253D77F633 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Nick, >> The only thing that i didn't understood is this line. >> First please tell me what is a byte value >>=20 >>> \x1b is a sequence you find inside strings (and "byte" strings, the >>> b'...' format). >>=20 >> \x1b is a character(ESC) represented in hex format >>=20 >> b'\x1b' is a byte object that represents what? >>=20 >>=20 >> >>> chr(27).encode('utf-8') >> b'\x1b' >>=20 >> >>> b'\x1b'.decode('utf-8') >> '\x1b' >>=20 >> After decoding it gives the char ESC in hex format >> Shouldn't it result in value 27 which is the ordinal of ESC ? I'm sorry are you not listening? 1b is a HEXADECIMAL Number. As a so-called programmer, did you = seriously not consider that? Try this: 1) Open a Web browser 2) Go to Google.com 3) Type in "Hex 1B"=20 4) Click on the first link 5) In the Hexadecimal column find 1B. Or open your favorite calculator, and convert Hexadecimal 1B to Decimal = (Base 10). - Benjamin --Apple-Mail=_44315BAF-0C1C-4AF3-91CB-0F253D77F633 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
The only thing that i didn't understood is this = line.
First please tell me what is a byte value

\x1b is a sequence you find inside strings (and "byte" = strings, the
b'...' format).

\x1b is a = character(ESC) represented in hex format

b'\x1b' is a byte object = that represents what?


>>> = chr(27).encode('utf-8')
b'\x1b'

>>> = b'\x1b'.decode('utf-8')
'\x1b'

After decoding it gives the = char ESC in hex format
Shouldn't it result in value 27 which is the = ordinal of ESC ?

I'm sorry = are you not listening?

1b is a HEXADECIMAL = Number.  As a so-called programmer, did you seriously not consider = that?

Try this:

1) = Open a Web browser
2) Go to Google.com
3) Type in "Hex = 1B" 
4) Click on the first link
5) In the = Hexadecimal column find 1B.

Or open your = favorite calculator, and convert Hexadecimal 1B to Decimal (Base = 10).

- = Benjamin


= --Apple-Mail=_44315BAF-0C1C-4AF3-91CB-0F253D77F633--