Base 64 encode the given input string, but safely.
Why using btoa() directly might not always work:
btoa() expects a "binary string" where each character is represented by a
single byte (0-255). Modern JavaScript strings, however, are encoded in
UTF-16 and can contain characters that require more than one byte (i.e.,
characters outside the Latin-1 range, such as those with code points greater
than 255).
Base 64 encode the given input string, but safely.
Why using btoa() directly might not always work: btoa() expects a "binary string" where each character is represented by a single byte (0-255). Modern JavaScript strings, however, are encoded in UTF-16 and can contain characters that require more than one byte (i.e., characters outside the Latin-1 range, such as those with code points greater than 255).