Mugipack
A small library to encode unicode strings or objects to base64
How to use
In browser
Add library
Instantiate and use
var mugipack = ;var encoded = mugipack;var decoded = mugipack;
In node
run npm install mugipack --save
var mugipack = var encoded = mugipackvar decoded = mugipack
Rationale
btoa()
is limited to ascii strings only, of course there are ways to overcome this, which depend on escaping or other libraries. I wish there was an easy way...
Algorithm
Object json-stringified, string converted to charcodes, every pair of charcodes encoded with one or two base64 symbols, resulted string prepended with dictionary (rules to convert it back) and some metadata. Numbers in dictionary and metadata converted to base62 to save more space (one symbol reserved as chunk separator '/' and one as array element separator '+', so it's 62 not 64)