dojo/request/xhr text charset

259 views Asked by At

I'm having troubles getting the correct encoding for a text file with xhr.

xhr(content.getContentUrl(), {
        handleAs: "text",
        headers: {  'Content-Type': 'text/plain; charset=iso-8859-1' }
    }).then(function (data) {
        console.log("DATA");
        console.log(data); ... );

The data object is a text file that should be with ISO-8859-1 characters, but I get a ? instead of the special character, it's like the response encoding is UTF-8

Example: "PER-RW-C-MC-013,B,ABB, P�rtico 5B. Fundaciones. Memoria de C�lculo,17/06/2011,23/06/2011,17/06/2011,01/07/2011,24/06/2011,20/07/2011,24/06/2011,19/07/2011,0,PER-RW-C-MC-013-C,PER-RW-C-MC-013-A"

Note: The content.getContentUrl() is a method from IBM filenet API that returns the text file URL in a filenet Repository.

Thanks in advance.

1

There are 1 answers

0
Jean-Claude Hujeux On

In response to your xhr request, you have code on your server that reads the file into a string and sends back that string as part of the response. This may very well be where the problem arises. See for example here (case of php) for a situation where this happened and a solution is suggested.