btoa() throws an InvalidCharacterError for Unicode chars like 🔥 ("\uD83D\uDD25"):
"Uncaught InvalidCharacterError: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range."
I created a pull request as suggestion to solve this by
btoa(unescape(encodeURIComponent(outputCode[index]))
Quick test by inverted function:
b64 = btoa(unescape(encodeURIComponent(outputCode[1])));
decodeURIComponent(escape(atob(b64))) == outputCode[1]; // must be the same as original text
btoa() throws an InvalidCharacterError for Unicode chars like 🔥 ("\uD83D\uDD25"): "Uncaught InvalidCharacterError: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range."
I created a pull request as suggestion to solve this by btoa(unescape(encodeURIComponent(outputCode[index]))
Quick test by inverted function: b64 = btoa(unescape(encodeURIComponent(outputCode[1]))); decodeURIComponent(escape(atob(b64))) == outputCode[1]; // must be the same as original text
Also see http://stackoverflow.com/questions/23223718/failed-to-execute-btoa-on-window-the-string-to-be-encoded-contains-characte