Created
November 1, 2017 23:03
-
-
Save C-Rodg/84649372c43e2a5eaa320fcd51fc1953 to your computer and use it in GitHub Desktop.
Convert a string to a byte array and then encode with Base64. Useful for putting complex data structures in XML.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const convertToBytes = (str) => { | |
return new TextEncoder('utf-8').encode(str); | |
}; | |
const dataString = 'TT12345,1:49:52 PM,10/15/13'; | |
// ODQsODQsNDksNTAsNTEsNTIsNTMsNDQsNDksNTgsNTIsNTcsNTgsNTMsNTAsMzIsODAsNzcsNDQsNDksNDgsNDcsNDksNTMsNDcsNDksNTE= | |
btoa(convertToBytes(dataString)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment