Forum Moderators: open
I have a little xmlhttprequest which opens a text file and puts it into a form.
The contents of the text file may contain special characters, such as an Æ which is Æ
When it goes into the form, it displays "?" instead of the special characters. I've tried changing my content type to charset=iso-8859-1 from utf-8 but that hasn't worked.
I've also tried this:
var s_p_c;
/*
Special characters array
*/
s_p_c = ['Æ', 'Á', 'Â', 'À', 'Å', 'Ã', 'Ä', 'Ç', 'É', 'Ê', 'È', 'Ë', 'Í', 'Î', 'Ì', 'Ï', 'Ñ', 'Ó', 'Ô', 'Ò', 'Ø', 'Õ', 'Ö', 'Ú', 'Û', 'Ù', 'Ü', 'Ý', 'á', 'â', 'æ', 'à', 'å', 'ã', 'ä', 'ç', 'é', 'ê', 'è', 'ë', 'í', 'î', 'ì', 'ï', 'ñ', 'ó', 'ô', 'ò', 'ø', 'õ', 'ö', 'ß', 'ú', 'û', 'ù', 'ü', 'ý', 'ÿ', 'Č', 'č', 'Ě', 'ě', 'Ň', 'ň', 'Ř', 'ř', 'Š', 'š', 'Ů', 'ů', 'Ž', 'ž', 'ő', 'Ő', 'ű', 'Ű', 'Ą', 'ą', 'Ć', 'ć', 'Ę', 'ę', 'Ł', 'ł', 'Ń', 'ń', 'Ś', 'ś', 'Ź', 'ź', 'Ż', 'ż', 'Ă', 'ă', 'Ğ', 'ğ', 'İ', 'ı', 'Ş', 'ş'];
var s_p_c_l;
s_p_c_l = ['Æ', 'Á', 'Â', 'À', 'Å', 'Ã', 'Ä', 'Ç', 'É', 'Ê', 'È', 'Ë', 'Í', 'Î', 'Ì', 'Ï', 'Ñ', 'Ó', 'Ô', 'Ò', 'Ø', 'Õ', 'Ö', 'Ú', 'Û', 'Ù', 'Ü', 'Ý', 'á', 'â', 'æ', 'à', 'å', 'ã', 'ä', 'ç', 'é', 'ê', 'è', 'ë', 'í', 'î', 'ì', 'ï', 'ñ', 'ó', 'ô', 'ò', 'ø', 'õ', 'ö', 'ß', 'ú', 'û', 'ù', 'ü', 'ý', 'ÿ', 'Č', 'č', 'Ě', 'ě', 'Ň', 'ň', 'Ř', 'ř', 'Š', 'š', 'Ů', 'ů', 'Ž', 'ž', 'ő', 'Ő', 'ű', 'Ű', 'Ą', 'ą', 'Ć', 'ć', 'Ę', 'ę', 'Ł', 'ł', 'Ń', 'ń', 'Ś', 'ś', 'Ź', 'ź', 'Ż', 'ż', 'Ă', 'ă', 'Ğ', 'ğ', 'İ', 'ı', 'Ş', 'ş'];// s_o_n is the content
var i;
var r;
for (i=0;i<s_p_c_l.length;i++)
{
/*
Find all of a character
Replace all instances of it
Move to the next
*/
r=new RegExp(s_p_c_l[i],"g");
s_o_n=s_o_n.replace(r,s_p_c[i]);
}
But this doesn't work. Any ideas?
Æ needs to be replaced with the octal-encoded equivalent which is [b]\306[/b]. Here is a useful resource which maps ISO-8859-1 HTML entity references to their octal equivalent:
[pjb.com.au...]