String.toUpperCase() does not uppercase accents

Posted on
  • If i upperCase string with accents, it does not work on accents!

    let txt= "béèàîâ";
    txt = txt.toUpperCase();
    console.log(txt); // Béèàîâ
    let txtUp = "bÉÈÀÎÂ";
    txtUp = txtUp.toUpperCase();
    console.log(txtUp); // BÉÈÀÎÂ
    for( let c of txt) {
      console.log(c, c.charCodeAt(0));
    }
    for( let c of txtUp) {
      console.log(c, c.charCodeAt(0));
    }
    

    espruino pico firmware 2v05.100 chrome appweb ide 0.73.7

  • For others, this is now reported in the Espruino bug tracker: https://github.com/espruino/Espruino/iss­ues/1866

    Espruino was originally only designed with ASCII in mind, so this doesn't work with char codes >127

    It shouldn't be too hard to fix, and for now you could actually overwrite String.prototype.toUpperCase with a JS version if you need it in a hurry

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

String.toUpperCase() does not uppercase accents

Posted by Avatar for Mrbbp @Mrbbp

Actions