• 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?

About

Avatar for Aifer @Aifer started