W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2011

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

From: Jorge <jorge@jorgechamorro.com>
Date: Fri, 4 Feb 2011 19:19:20 +0100
Message-ID: <695B8859-DC72-49F7-A23A-5C3260E67544@jorgechamorro.com>
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.
Received on Friday, 4 February 2011 10:19:20 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:30 UTC