View Full Version : problem with special characters

08-22-2004, 05:41 PM
Hello everyone,

I am relatively new to scripting. I am using javascript in ASP pages.
I have an encoding problem with Javascript to display special characters.
I extract the data from my xml file.
Here is a label from my xml file
I have a function called GetText("LblName") that returns the corresponding string with the label name.
When I do GetText("LblCompany") it returns me Société
Now i want the above text to be seen in javascript alert as "Société".

I can't figure out how do i handle the é to be shown as "é"!

I have tried to use Escape and Unescape functions but don't seem to get the result as expected.

When I apply Escape function to alert(escape("<%=GetText("LblCompany")%>")) it returns me
I am aware that using Unescape would show "&" and other related chars.

Can someone please tell me how to get this sorted out?


08-22-2004, 06:16 PM
Just some ideas...

Did you try just doing this?
Is that returning wrong results?

If so look at the generated source code.
Are the special characters showig up correctly in the source of the page?

Do you have the correct encoding set for the page?

08-22-2004, 06:58 PM
Hi there,

Yes the special characters do show up right on the page.
For instance if i say alert("Société"); it does appear right. But now when I am inside my asp page the gettext() function which is written in vbscript extracts the data as Soci%26%23233%3Bt....
But this does show the expected characters on the page if the language is vbscript. Now if i change the language of the page to javascript and use the vbscript tags(<%%>) in them and show the same text, then this text is not converted to the special char "é"

One of my friends suggested me to use decodeURI but in vain.

The bottomline is that the text shows up right when the language is vbscript but doesn't show up when it is javascript.

My javascript is not able to convert the "&"s "%"s and other special characters.

What do you mean my having correct encoding set for the page? You mean to say under tools - internet options - advanced options?

Any other suggestions?

Thank You

08-22-2004, 07:47 PM
What I mean by encoding:

unescape and decodeURI only change certain characters and that is why it is not working.

I think you are going to have to write your own function that converts that characters over, unless someone else here knows any other solution.