Message253766
| Author |
martin.panter |
| Recipients |
docs@python, martin.panter, matrixise, mouse07410, r.david.murray |
| Date |
2015年10月30日.22:50:38 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1446245438.49.0.294822901895.issue25495@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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? |
|