Page 1 of 1

Gantt 5.0.0 - issue with characters like á and ñ

Posted: Fri May 06, 2022 1:23 pm
by MauriceLapre

Hi,

I'm having an issue with characters like á and ñ in the task name. They end up being unknown, question mark symbols:

charactersissue-1.png
charactersissue-1.png (3.67 KiB) Viewed 816 times

The server response via Ajaxhelper.fetch is fine:

charactersissue-2.png
charactersissue-2.png (26.56 KiB) Viewed 816 times

But then after parsing, in the data.parsedJson it's scrambled:

charactersissue-3.png
charactersissue-3.png (26.56 KiB) Viewed 816 times

Part of my code:

AjaxHelper.fetch(fetchUrl, {
                mode : 'no-cors',
                method : 'POST',
                parseJson : true,                
body :JSON.stringify(requestData),
headers : { 'Content-Type': 'application/json', 'Request-Source': 'XMLHTTP', 'Request-Type': 'XMLHTTP'
}
}).then(function(response) { console.log('response'); console.log(response); return iscloud == true ? response : response.text(); // = true }).then(function(data) { console.log('response to text if needed'); console.log(data); console.log(data.parsedJson);

Am I missing an encoding setting or something?

Thank you.


Re: Gantt 5.0.0 - issue with characters like á and ñ

Posted: Fri May 06, 2022 2:00 pm
by tasnim

Hi,
Could you please provide raw server response in clear text?

Best regards,
Tasnim


Re: Gantt 5.0.0 - issue with characters like á and ñ

Posted: Fri May 06, 2022 3:51 pm
by MauriceLapre

Raw server response:

{
    "2UMWOL": [
        {
            "code": "11661",
            "comments": "",
            "parentwo": "",
            "equipment": "ALG.000",
            "priority": "P2",
            "startdate": "2022-05-02 00:00:00.0",
            "costcode": "",
            "assignedto": "MAURICE.LAPRE",
            "rstatus": "R",
            "eamproject": "",
            "wotype": "BRKD",
            "equipmentdesc": "Gebouwen Algemeen",
            "enddate": "2022-05-06 00:00:00.0",
            "schedenddate": "06-MAY-2022",
            "organization": "SD01",
            "targetdate": "02-MAY-2022",
            "name": "Test ~ñ à á !@#$%^&*()",
            "requestend": "",
            "requeststart": "",
            "department": "*",
            "class": "",
            "supervisor": "",
            "status": "WOP"
        }
    ]
}

Re: Gantt 5.0.0 - issue with characters like á and ñ

Posted: Sat May 07, 2022 2:48 pm
by mats

If I run this in our basic sample, it works just fine

AjaxHelper.fetch('../_datasets/launch-saas.json', {
    mode      : 'no-cors',
    method    : 'POST',
    parseJson : true,
    body      : JSON.stringify({ foo : 'bar' }),
    headers   : {
        'Content-Type'   : 'application/json',
        'Request-Source' : 'XMLHTTP',
        'Request-Type'   : 'XMLHTTP'
    }
}).then(function(data) {
    console.log('response to text if needed');
    console.log(data);
    console.log(data.parsedJson);
});

Output in image, so must be something on your server.


Re: Gantt 5.0.0 - issue with characters like á and ñ

Posted: Mon May 16, 2022 7:54 pm
by MauriceLapre

Thanks for investigating. But how can it be something on my server when my server responds correctly? And only after parsing the response data via the Ajaxhelper.fetch, the weird characters show up?


Re: Gantt 5.0.0 - issue with characters like á and ñ

Posted: Mon May 16, 2022 7:59 pm
by mats

What's your server responding, can you please paste headers?

Related discussion: https://stackoverflow.com/questions/55282444/javascript-fetch-characters-with-encoding-issues


Re: Gantt 5.0.0 - issue with characters like á and ñ

Posted: Mon May 16, 2022 8:04 pm
by MauriceLapre

It's indeed

Content-Type: application/json;charset=ISO-8859-1

. So, characters seem the same but aren't, I assume.

I have requested to change this to utf-8, assume that should solve the issue.

Thanks for that hint, Mats!


Re: Gantt 5.0.0 - issue with characters like á and ñ

Posted: Mon May 16, 2022 8:10 pm
by mats

Glad it's resolved :)