Native base64 utility methods

Mathias Bynens mathias at qiwi.be
Mon May 5 00:54:52 PDT 2014


On 5 May 2014, at 00:00, Andrea Giammarchi <andrea.giammarchi at gmail.com> wrote:

> as generic global utility it would be also nice to make it compatible with all strings.

For backwards compatibility reasons, `atob`/`btoa` should probably continue to work in exactly the same way they work now (i.e as per http://whatwg.org/html/webappapis.html#atob). Otherwise, any existing code that uses `atob`/`btoa` before UTF-8-decoding or after UTF-8-encoding, including your snippet, would suddenly break.

Like you demonstrated, it’s easy enough to encode or decode the input using UTF-8 or any other character encoding before passing to `atob`/`btoa`. (E.g. http://mothereff.in/base64)



More information about the es-discuss mailing list