Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Special characters problem.

Hi,

I have a problem with some special characters with my Ajax application. I use an asp-site which use a javascript to query a database by requesting an asp-file to print some html which I then display by using innerhtml. The asp-file uses vbscript and the Response.Write-syntax.

A part of the javascript looks like this:

var url="getsupps.asp";
url=url+"?s="+URLEncode(strSupplier);
url=url+"&f="+URLEncode(strFilepath);
url=url+"&u="+URLEncode(strUsername);
url=url+"&l="+intList;
url=url+"&text="+URLEncode(strText);
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
}
}

In Firefox, each special character is replaced by a '�', whichever character encoding I use on the first page, I guess this encoding doesn't apply to the innerhtml. In IE6 these special characters are replaced by a '?' and also replacing the coming 3 characters after the special character, i.e. 'sample text' = 'sample ?xt'.

I've searched for an answer for quite some time now but can't find an answer, thanks for your time! :)

Regards,
Peros
[1394 byte] By [peros] at [2007-11-11 11:58:38]
# 1 Re: Special characters problem.
Hey,

I just realized that the responseText replies the wrong chars, and it replies the wrong chars based on browser. I've tried to set encoding on the xmlHttp-"request" by using:
xmlHttp.setRequestHeader("Content-Type", "charset=iso-8859-1");
but it doesn't make any difference. Are there any other ways to control the information transaction between the javascript and the asp-file?
peros at 2007-11-11 23:41:56 >