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

Javascript problem with document.write and accented characters

Hi,

I have a web page where I put a javascript and where its source is an ASP.NET application. So it looks like this:

<script language="javascript" src="/js.aspx type="text/javascript"></script>

This web page has the meta tag for encoding:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

The ASP page is printing some document.write with data taken from a database. If I go directly to the js.aspx page, I see this:

document.write('Mon pre a t l');

The french accent are there which is good.

But when I go to my test page, I see things like this:

"Mon père a ètè lè"

All the french accent have been converted in a non-readable format.

I tried to put the charset property to the script tag (charset="iso_8859-1") and it doesn't work. I also check encoding of my ASP page but it still doesn't work.

After googling a lot in vain, I hope I'm not the only having this problem!

Any idea or any solution??

Thanks!

Stephane
[1119 byte] By [steph2004] at [2007-11-11 7:38:52]
# 1 Re: Javascript problem with document.write and accented characters
I don't think you can have anything but a .js file as the src of a script tag that has javascript as it's type. Also you're missing 2 closing quotes.
JPnyc at 2007-11-11 23:34:59 >
# 2 Re: Javascript problem with document.write and accented characters
Hi,

I've done this a few times with PHP and ASP pages and I didn't have any trouble. But this time with ASPX page, there's a problem with the encoding somewhere... Is there a way to dynamically convert accented charaters using javascript or .net??

Thanks

Stephane
steph2004 at 2007-11-11 23:36:05 >
# 3 Re: Javascript problem with document.write and accented characters
I've done a lot of things and it's working now... I'm not 100% sure but it seems it's because I added responseEncoding="iso-8859-1" to the ASP.Net Page directive.

It works now so I won't touch it again! :)

Steph
steph2004 at 2007-11-11 23:37:03 >