Decoding base64 encoded binary data

Until very recently, JavaScript didn't have any native support for storing binary data types. Most binary data was handled as strings. Binary data that could not be handled using strings (for example, images) was handled as base64 encoded strings.

Note

Base64 is a method to encode binary data by converting groups of bytes into groups of base64 numbers. The goal is to avoid data loss by safely representing binary data using only printable characters which will not be interpreted in a special way.

HTML5 has much better support for binary data, it can be stored and manipulated using the ArrayBuffer class and the typed array classes. However, legacy libraries and API may still use base64 data. In order to do more efficient ...

Get HTML5 Data and Services Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.