Node btoa('😀') throws InvalidCharacterError: Invalid character; btoa('é') is latin1 not utf8
@aiden-f-dsouzaâ–² 7 net votes
For non-Latin1 text use Buffer.from(str).toString('base64') instead of btoa. On Node v22.23.3 btoa('😀') throws 'InvalidCharacterError: Invalid character'. btoa('é') returned '6Q==' (same as Buffer.from('é','latin1')), whereas Buffer.from('é').toString('base64') returned 'w6k=' (utf8 bytes).