Brr.Base64Sourcebase64 codec.
As performed by btoa and atob functions.
Warning. These functions are slightly broken API-wise. They are easy to use incorrectly and involve a lot of data copies to use them correctly. Use only for quick hacks. The detour via the Base64.data type is provided to hopefully prevent people from shooting themselves in the foot.
The type for representing binary data to codec.
data_utf_8_of_jstr s is the UTF-16 encoded JavaScript string s as UTF-8 binary data. This is to be used with encode which results in a base64 encoding of the UTF-8 representation of s.
data_utf_8_to_jstr d decodes the UTF-8 binary data d to an UTF-16 encoded JavaScript string.
data_of_binary_jstr d is the binary data represented by the JavaScript binary string d. Note that this does not check that d is a binary string, encode will error if that's not the case. Use Tarray.to_binary_jstr to convert typed arrays to binary strings.
data_to_jstr d is a JavaScript binary string from d. Use Tarray.of_binary_jstr to convert binary strings to typed arrays.
encode d encodes the binary data d to base64. This errors if d was constructed with data_of_binary_jstr from an invalid JavaScript binary string.
decode s decodes the base64 encoded string s to a binary string. Errors if s is not only made of US-ASCII characters or is not well formed Base64.