in nodejs terminal:
> var s = String.fromCharCode(0x00,0x2B,0x20,0xFC); > var t = new Buffer(s).toString('base64'); > console.log(s); + ü > console.log(t); ACsgw7w= >
string is String.fromCharCode(0x00,0x2B,0x20,0xFC) , the base64 string is "ACsgw7w="
and in Espruino Web IDE left-hand terminal:
>var s = String.fromCharCode(0x00,0x2B,0x20,0xFC); ="\x00+ \xFC" >var t = btoa(s); ="ACsg/A=="
string is String.fromCharCode(0x00,0x2B,0x20,0xFC) , the base64 string is "ACsg/A=="
Why the same string gets different base64 encoded string in Espruino and nodejs?
@Aifer started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
in nodejs terminal:
string is String.fromCharCode(0x00,0x2B,0x20,0xFC) , the base64 string is "ACsgw7w="
and in Espruino Web IDE left-hand terminal:
string is String.fromCharCode(0x00,0x2B,0x20,0xFC) , the base64 string is "ACsg/A=="
Why the same string gets different base64 encoded string in Espruino and nodejs?