Some time ago I saw a website that encoded game replay data into unicode characters so that you could copy-and-paste the address to share it with friends. I basically want to do the same thing -- I've got some data in a JavaScript object and I want to put it into the address bar.
I know I can use jQuery.param or something like that, but I want a much more compact format.
Turns out this is a little tricky to Google. Most search results turn up URL shorteners, which is distinctly different. I am not trying to store a short URL in my database for later lookup. All the data should be in the URL itself.
What encoding can I use for this? A link or description of the algorithm is fine, but impementations for Node/JavaScript would be even better.
I only need to support the latest version of Chrome stable, so I don't care if older browsers can't handle the unicode. I think I'll put the data in the fragment portion (after #
) so I only need to support whatever encoding rules apply to that piece. I think just about anything is allowed, no?
There you go https://github.com/qntm/base65536 & https://www.npmjs.com/package/base65536
Base65536 is a binary encoding optimised for UTF-32-encoded text and Twitter. This JavaScript module, base65536, is the first implementation of this encoding.
It featured on hackernews some time ago.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With