Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #109888
| 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 | Mon, 13 Jun 2016 01:33:13 -0400 |
| Lines | 29 |
| Message-ID | <mailman.28.1465795996.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> <mailman.26.1465788060.2288.python-list@python.org> <575e4198$0$1588$c3e8da3$5496439d@news.astraweb.com> <1465795993.2881334.635716385.023A423E@webmail.messagingengine.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de cRjELnJGhK4TTovtsNSxowJz0mu1Y5nBFlrXH8mqzGNg== |
| Return-Path | <random832@fastmail.com> |
| 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; 'binary': 0.05; 'bytes.': 0.07; 'subject:skip:b 10': 0.07; 'base64': 0.09; 'bytes,': 0.09; 'encode': 0.09; 'meaningful': 0.09; 'mode,': 0.09; 'received:internal': 0.09; 'skip:\\ 40': 0.09; 'will,': 0.09; 'python': 0.10; 'assume': 0.11; 'itself.': 0.11; 'encoding': 0.15; 'decode': 0.16; 'ebcdic': 0.16; 'expects': 0.16; 'message- id:@webmail.messagingengine.com': 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; 'bytes': 0.18; 'string,': 0.18; 'library': 0.20; 'suppose': 0.22; 'file.': 0.22; '(or': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'example': 0.26; '13,': 0.29; 'embed': 0.29; 'mode.': 0.29; "can't": 0.32; 'returned': 0.32; "d'aprano": 0.33; 'steven': 0.33; 'surely': 0.33; 'open': 0.33; 'file': 0.34; 'could': 0.35; 'text': 0.35; 'unicode': 0.35; 'but': 0.36; 'instead': 0.36; 'mode': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'agree': 0.37; 'expect': 0.37; 'say': 0.37; 'things': 0.38; 'received:66': 0.38; 'why': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'header:Message-Id:1': 0.61; 'fact,': 0.67; 'email,': 0.69; 'serial': 0.70; 'receive': 0.71; 'introduce': 0.79; 'counts': 0.81; 'hardly': 0.84; 'provide,': 0.91; 'good,': 0.93 |
| 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=qKCdepXjSAgyIQ+/ef+2TjZf/9M=; b=nW8F8r Hv7ggb9ihrDjbkLF+3E8Sz8MdXizhR8+t0C+augrd5InUWv0u5iu8aRS+wksAFTb e5d9Oj3OijH/VFagkyK0GsxmIENCcJr6hffd0+t214NmPA4MXYniX3iaEUy2bJSn XHAgBca9BU0SxZDrKG9XrRYmR6jbIqGphsD7Q= |
| 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=qKCdepXjSAgyIQ+ /ef+2TjZf/9M=; b=hZucSrtsOWHqM/mZnD+B5Bi2XDsp4flitpn70PRK12Y9Skq 16KSJ/Cao6Y5DsG48DXstmKqpIaqHnXHjUc1GjZLu2y1niJrtfYw2UpUVMnkrEn6 pKk7bjMmVn8sGJ7I8c6AfegRmvW4sWWgm3iPdrEG4SsEnH+pu3oYSMT5K66w= |
| X-Sasl-Enc | QZAdoLlbh+d6ofgS0hXYBJ2pA9TSH05fPaQ/acivc198 1465795993 |
| X-Mailer | MessagingEngine.com Webmail Interface - ajax-aff28cd1 |
| In-Reply-To | <575e4198$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 | <1465795993.2881334.635716385.023A423E@webmail.messagingengine.com> |
| X-Mailman-Original-References | <ccd85c61-263c-4ebd-b47f-b35fafa3f521@googlegroups.com> <575e18f1$0$1588$c3e8da3$5496439d@news.astraweb.com> <1465788057.2854167.635655857.445F242C@webmail.messagingengine.com> <mailman.26.1465788060.2288.python-list@python.org> <575e4198$0$1588$c3e8da3$5496439d@news.astraweb.com> |
| Xref | csiph.com comp.lang.python:109888 |
Show key headers only | View raw
On Mon, Jun 13, 2016, at 01:16, Steven D'Aprano wrote: > Suppose instead it returned the Unicode string 'AUERFg=='. That's all > well and good, but what are you going to do with it? You can't > transmit it over a serial cable, because that almost surely is going > to expect bytes, so you have to encode it. You can't embed it in an > email, because that also expects bytes. Unless you're using a library that expects to receive strings and encode them itself. Such as, in the example you so helpfully provide, a file opened in text mode. > You could write it to a file. If the file is opened in binary mode, > you have to encode the Unicode string to bytes before you can write > it. If the file is opened in text mode, Python will accept your > Unicode string and encode it for you, which could introduce non- > base64 characters into the file. Consider if the file was opened > using UTF-16: > > \x00A\x00U\x00E\x00R\x00F\x00g\x00=\x00= > > hardly counts as base64 in any meaningful sense. Why do you say these things like you assume I will agree with them. It doesn't, in fact, introduce non-base64 characters because base64 characters are *characters*, not *bytes* and UTF-16 (or EBCDIC or whatever) is a perfectly valid encoding of those *characters*, and the recipient will, naturally, open that file in text mode in the same encoding, and receive the same string, which it can then decode as base64.
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