[whatwg] Specs for window.atob() and window.btoa()

Jorge jorge at jorgechamorro.com
Fri Feb 4 10:19:20 PST 2011

On 04/02/2011, at 17:49, Boris Zbarsky wrote:
> On 2/4/11 11:37 AM, Jorge wrote:
>> Wrt to the note "some base64 encoders add newlines or other whitespace to their output. atob() throws an exception if its input contains characters other than +/=0-9A-Za-z, so other characters need to be removed before atob() is used for decoding" in http://aryeh.name/spec/base64.html , I think that in the end it's better to ignore any other chars instead of throwing, because skipping over any such chars while decoding is cheaper and requires less memory than scanning the input twice, first to clean it and second to decode it, something you'd not want to end up doing -just in case- everytime.
> The problem is that at least some current browsers (which ones?) throw.  So you wouldn't be able to rely on the non-throwing behavior anyway....  :(

On the other hand, it will be so forever unless the spec says *not* to throw but to skip over instead, so that in a few years the cleanup can be ~safely skipped.

More information about the whatwg mailing list