Minecraft – tellraw problem with portuguese and spanish text

minecraft-commandsminecraft-java-edition

always when the message contains some accent in some letter, it returns an error in json instead of working.

Text Example: ýay

Result: [RCON] Invalid chat component: End of input at line 1 column 36 path $[1]…ellraw @a [{"text":" C=ay"}<–[HERE]

Updated

Using the help of your answer, I solved the problem. Thank You~ <3

Source: https://stackoverflow.com/questions/21647928/javascript-unicode-string-to-hex

module.exports = {

encode: function(tinythis, finalv = false) {
    var hex, i;

    var result = "";
    for (i = 0; i < tinythis.length; i++) {

        hex = tinythis.charCodeAt(i).toString(16);

        if (!finalv) {
            result += ("000" + hex).slice(-4);
        } else {
            result += '\\u' + ("000" + hex).slice(-4);
        }

    }

    return result;

},

decode: function(tinythis) {
    var j;
    var hexes = tinythis.match(/.{1,4}/g) || [];
    var back = "";
    for (j = 0; j < hexes.length; j++) {
        back += String.fromCharCode(parseInt(hexes[j], 16));
    }

    return back;
}

};

       const hexC = require('./file.js');


        for (var items in cmd) {
            cmd[items].text = hexC.encode(cmd[items].text, true);
        }

        console.log(JSON.stringify(cmd).replace(/\\\\u/g, '\\u'));
        this.cmd = 'tellraw ' + player + ' ' + JSON.stringify(cmd).replace(/\\\\u/g, '\\u');

Best Answer

If it's a JSON error message you're getting, you should be able to use JSON escape codes (here's an online tool) to work around the issue: try saying \u00FDay instead of ýay.