Message253766
I was only referring to the original Python documentation and library. See the base64.encode() implementation for an example which does do this 57-byte pre-chunking. Simplified:
MAXLINESIZE = 76 # Excluding the CRLF
MAXBINSIZE = (MAXLINESIZE//4)*3 # 57
...
while True:
s = input.read(MAXBINSIZE)
if not s:
break
line = binascii.b2a_base64(s)
output.write(line)
Here’s my attempt to rewrite the doc (3.6 version):
'''
Convert binary data to the base 64 encoding defined in :rfc:`4648`. The return value includes a trailing newline ``b"\n"`` if *newline* is true.
To be MIME-compliant, base 64 output should be broken into lines at most 76 characters long. One way to do this is to call this function with 57-byte chunks and ``newline=True``. Also, the original PEM context-transfer encoding limited the line length to 64 characters.
'''
But if PEM is long gone as you say, perhaps we don’t need that last sentence? |
|
Date |
User |
Action |
Args |
2015-10-30 22:50:38 | martin.panter | set | recipients:
+ martin.panter, r.david.murray, docs@python, matrixise, mouse07410 |
2015-10-30 22:50:38 | martin.panter | set | messageid: <1446245438.49.0.294822901895.issue25495@psf.upfronthosting.co.za> |
2015-10-30 22:50:38 | martin.panter | link | issue25495 messages |
2015-10-30 22:50:38 | martin.panter | create | |
|