I have a website which apperently removes the correct encoding (ISO-8859-1) from a string and sends it wrong.
I have this encoding specified in my HTML
<meta charset="ISO-8859-1">
I load my javascript via
<script type="text/javascript" charset="ISO-8859-1" src="...
I send for Information via JQuery Ajax Request like this (with german special character 'ö' and 'ä'):
$.ajax({
url: '..',
type: 'POST',
contentType: 'application/xml;charset=ISO-8859-1',
data: xmlRequest.html(),...
This is translated into a request and in the chrome developer tools I see this in the Request Header:
..
Content-Type: application/xml;charset=UTF-8
..
What happened there?
Of course the special characters are encoded wrong ("ö" instead of "ö") the server can't understand me and i get an error.
Because I had the same problem, I'll provide a solution that worked for me. Background: Microsoft Excel is too stupid to export a CSV-File in charset UTF-8:
$.ajax({
url: '...',
contentType: 'Content-type: text/plain; charset=iso-8859-1',
// This is the imporant part!!!
beforeSend: function(jqXHR) {
jqXHR.overrideMimeType('text/html;charset=iso-8859-1');
}
});