Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #109881
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Random832 <random832@fastmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: base64.b64encode(data) |
| Date | Sun, 12 Jun 2016 23:20:57 -0400 |
| Lines | 22 |
| Message-ID | <mailman.26.1465788060.2288.python-list@python.org> (permalink) |
| References | <ccd85c61-263c-4ebd-b47f-b35fafa3f521@googlegroups.com> <575e18f1$0$1588$c3e8da3$5496439d@news.astraweb.com> <1465788057.2854167.635655857.445F242C@webmail.messagingengine.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de mCmZUzYePz9P+TYCbAPZxQ2t6oAeO0nqNhbCk0QAoSYw== |
| Return-Path | <random832@fastmail.com> |
| 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; 'binary': 0.05; 'subject:skip:b 10': 0.07; 'base64': 0.09; 'bytes,': 0.09; 'naturally': 0.09; 'protocols.': 0.09; 'received:internal': 0.09; 'output': 0.13; 'encoding': 0.15; 'ebcdic': 0.16; 'manner,': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'peek': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.212': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'string': 0.17; 'byte': 0.18; 'bytes': 0.18; 'variable': 0.18; 'arguments': 0.22; 'seems': 0.23; 'header:In- Reply-To:1': 0.24; 'specifically': 0.28; 'values': 0.28; 'convenience': 0.29; 'idea?': 0.29; 'convert': 0.29; 'print': 0.30; 'e.g.': 0.30; 'choosing': 0.33; "d'aprano": 0.33; 'displayed': 0.33; 'steven': 0.33; 'except': 0.34; 'text': 0.35; 'exist': 0.35; 'unicode': 0.35; 'but': 0.36; 'needed': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'display': 0.37; '12,': 0.37; 'received:66': 0.38; 'represent': 0.38; 'data': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'header:Message-Id:1': 0.61; 'is.': 0.63; 'safe': 0.63; 'wish': 0.71; 'nonsense.': 0.84; 'absolutely': 0.88 |
| DKIM-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=c/6cgUFY1YTbepCk/cIqnOP7ONM=; b=GAQ40i WCb4Wk2CxJHXP7QTXwEYI3Dvub6TbmGcYRUAxST+RhsGJ26GPURMoqv8mCBCfyWl f13OduWvxS+j72iXdlsvZu6sC0Kq1XtG2t1qS9slr5exMv4h7caL8uou+tgNs1Qs FX5Xr0+QiGAJtU3NHMymNSamCnH9qQP0p0PQg= |
| DKIM-Signature | v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=c/6cgUFY1YTbepC k/cIqnOP7ONM=; b=P+nytbeWVp1vl+Wm2AIERxAym/E8YjJkuCMY2nPiefFGNRv tPA+wCfNpOCsBrcTlzmKSxp13JqNt/Ls/nQiWdOJCh25ilOqh5IUfzLD4ZLkw5WT RMGDTzJNgs2ml8KOZPVIZlvnp7DIfH2DojQMvzo8qIm1G5ow2BQOZpb+pXAk= |
| X-Sasl-Enc | ra//SmK7dm8NxFE8aA74g/6e6rUZ0KsqMzrrIFdaal1I 1465788057 |
| X-Mailer | MessagingEngine.com Webmail Interface - ajax-aff28cd1 |
| In-Reply-To | <575e18f1$0$1588$c3e8da3$5496439d@news.astraweb.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| 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> |
| X-Mailman-Original-Message-ID | <1465788057.2854167.635655857.445F242C@webmail.messagingengine.com> |
| X-Mailman-Original-References | <ccd85c61-263c-4ebd-b47f-b35fafa3f521@googlegroups.com> <575e18f1$0$1588$c3e8da3$5496439d@news.astraweb.com> |
| Xref | csiph.com comp.lang.python:109881 |
Show key headers only | View raw
On Sun, Jun 12, 2016, at 22:22, Steven D'Aprano wrote: > That's because base64 is a bytes-to-bytes transformation. It has > nothing to do with unicode encodings. Nonsense. base64 is a binary-to-text encoding scheme. The output range is specifically chosen to be safe to transmit in text protocols. > > That is, the b64_encoded_data variable is of type 'bytes' and when > > you peek inside it's a string (made up of what seems to be only > > characters that exist in Base 64). > > If you print or otherwise display bytes, for the convenience of human > beings, those bytes are displayed as if they were ASCII. E.g. the byte > 0x61 is displayed as 'a'. Good idea? Bad idea? I can see arguments > either way, but that's how it is. There's absolutely no rational basis for choosing "0x41-0x5A, 0x61-0x7A, 0x30-0x39, 0x2B, 0x2F" as the output range except for what characters those values represent in ASCII. And if you needed to smuggle some binary data through an EBCDIC system in the same manner, you would naturally wish to convert it to the EBCDIC bytes corresponding to those same characters.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
base64.b64encode(data) Marcin Rak <mrak@sightlineinnovation.com> - 2016-06-12 11:56 -0700
Re: base64.b64encode(data) Marko Rauhamaa <marko@pacujo.net> - 2016-06-12 22:26 +0300
Re: base64.b64encode(data) Steven D'Aprano <steve@pearwood.info> - 2016-06-13 12:22 +1000
Re: base64.b64encode(data) Random832 <random832@fastmail.com> - 2016-06-12 23:20 -0400
Re: base64.b64encode(data) Steven D'Aprano <steve@pearwood.info> - 2016-06-13 15:16 +1000
Re: base64.b64encode(data) Random832 <random832@fastmail.com> - 2016-06-13 01:33 -0400
Re: base64.b64encode(data) Marko Rauhamaa <marko@pacujo.net> - 2016-06-13 09:45 +0300
Re: base64.b64encode(data) Steven D'Aprano <steve@pearwood.info> - 2016-06-13 20:35 +1000
Re: base64.b64encode(data) Random832 <random832@fastmail.com> - 2016-06-13 09:36 -0400
Re: base64.b64encode(data) Steven D'Aprano <steve@pearwood.info> - 2016-06-22 01:56 +1000
Re: base64.b64encode(data) Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-06-13 20:20 -0400
Re: base64.b64encode(data) Michael Torrie <torriem@gmail.com> - 2016-06-13 09:15 -0600
Re: base64.b64encode(data) Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-14 11:04 +1200
Re: base64.b64encode(data) Chris Angelico <rosuav@gmail.com> - 2016-06-14 03:07 +1000
Re: base64.b64encode(data) Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-14 11:12 +1200
Re: base64.b64encode(data) Random832 <random832@fastmail.com> - 2016-06-13 21:19 -0400
csiph-web