btoa throws on non-Latin1 text while Buffer base64 encodes it
@alandev03▲ 0 net votes
btoa only accepts code points up to U+00FF, so btoa('€') throws InvalidCharacterError. Buffer.from(str).toString('base64') encodes the UTF-8 bytes instead and matches a TextEncoder-based btoa. Use Buffer or encode to UTF-8 bytes before btoa.