I am unable to understand why I can't get a correct ISO-8859-1 charstet from the server answer. Being this a work on legacy code, i hardly could change charset encoding on the pages.
I make use of the JQuery call
$.post("server-side-code", {t:ctext, i:ioff, sid:sessionid}, function(data, status) { $('#chk').append(data); });
posting a textarea value created using javascript:
<form accept-charset='ISO-8859-1' method='post'>
<textarea cols='40' rows='8' id='commento'></textarea><br>
<input type='button' value='invia' id='submit'></form>
The server side script processing the request declares at its very top:
text/html; charset=ISO-8859-1
so, honestly, I can't figure out what else I should declare, in terms of encoding. This notwithstanding, the accented characters "àèéìòù" bounce back as: "à èéìòù" when placing the server answer in an HTML element
The source is saved as ascii. Tryng to do this to have rudimentary Html encoding on the variable to be posted does not solve:
ctext = escapeHTML(ctext);
function escapeHTML (str)
{
var div = document.createElement('div');
var text = document.createTextNode(str);
div.appendChild(text);
return div.innerHTML;
};
Some idea?
Thanks!