Open tympanix opened 7 years ago
Base64 encoding of text works but binary data (from typed arrays) still seems problematic. One may have to resolve to one of the solutions [found here](https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_.232_.E2.80.93_rewriting_atob()_and_btoa()_using_TypedArrays_and_UTF-8) which involves using polyfill. Closing momentarily. I will get back when a solution is found.
Now supports binary base64 conversion through base64-js. I have added base64-js as an dependency, which means you will have to include the script in your browser for base64 encoding to work:
<script src="base64js.min.js"></script>
Achieving robust base64 encoding/decoding is problematic without this polyfill if you don't like having third party dependencies. I have been testing with real world files, which works flawlessly.
Bump!
I found a bug where a
Uint8Array
could not be marshaled into base64 due to the relatively small call stack size of Javascript (I suspect recursion). The old limit was 128KiB. I was able to increase the size to 128MiB (10x old limit) before aRangeError: Invalid string length
is thrown.Furthermore,
xml2json
of base64 now returns anUint8array
of the data converted back from base64 to binary (opposed to just removing the base64 tag and returning the base64 content). It handles unicode characters as described here both to and from base64. Since this is in contradiction with the previous implementation, I have issued a new minor version.