Anyway, I wonder why we need two base64 decoding functions. Sure, they
serve different purposes, but the inner parts mostly do the same (apart
from error handling). Shouldn't we consolidate this? This surely would
require some rework (e.g. the state needs to be saved between b64decode
calls for robust mime decoding), but I guess it's worth the time to have
cleaner code.
I would surely prefer the decoding loop from mime_decode_base64 over the
one in b64encode, not only because it's much shorter (20 lines vs. 50)
and very much easier to read (I highly doubt the claims of b64encode
"written out in a straightforward way" and "compact loop is messy").
Note that I might be a little biased here, as most of mime_decode_base64
was written by me :)