I need to convert a UTF-8 string to base64 for consumption by gmail's API. (Use case is similar to this one.)
Normally in Node, you'd do this with the server-side
Buffer() function, like this:
const encodedMessage = Buffer.from('Hello world! 🙂').toString('base64');
Unfortunately, Retool's JS browser environment doesn't support
Buffer(). Retool scripting does support
btoa(), but unfortunately
btoa() can't handle non-ASCII characters so it won't solve for my use case:
const encodedMessage = btoa('Hello world!'); // ok
const encodedMessage = btoa('Hello world! 🙂'); // crashes due to non-ASCII emoji
So my question is: how can I encode a UTF-8 string into base64 in Retool?
Note: This question has been asked already, and the suggested solution was to use this library that ports
Buffer() to the browser. But unfortunately the CDN link that's given in the answer (https://firstname.lastname@example.org/index.min.js) isn't in UMD format, so it's not usable as a Retool library. I haven't had any luck yet in finding a UMD-friendly buffer library.