Entry
How can i Escape Special Chars in NN6? alert(escape('Würzburg')); only Alerts a 'W'
Jul 10th, 2003 02:51
Jens Kisters, Jean-Bernard Valentaten, Aimé Ah-Jaco,
If you want to see special characters in the alert box, you would write
the corresponding ascii code.
To have "Würzburg", write :
alert('W\xfcrzburg');
ascii code of special characters :
ß => \xdf
à => \xe0
â => \xe2
ä => \xe3
ç => \xe7
è => \xe8
é => \xe9
ê => \xea
ë => \xeb
î => \xee
ï => \xef
ô => \xf4
ö => \xf6
ù => \xf9
û => \xfb
ü => \xfc
jk> How does this help with escaping (rawurlencoding) a String?
jk> Do i have to do this manually? Why doesnt the escape funtion work
jk> like its supposed to?
escape function would output the hexadecimal code preceeding by %. For
example, you obtain visually for Würzburg W%FCrzburg. This function is
useful to encode an URL string. It's very damage for you, you have to do
this manually
jk> thats what it does not do, thats the problem, It makes a 'W'
jk> instead of W%FCrzburg. The alert is for debugging purposes only.
Hmm, seems to me that you do have another bug then.
Have you ever tried to use the encodeURI() function, it does the same
as the escape() function, but it came up with js 1.5 and will replace
the escape() function in upcoming versions of js.
jk> yeah i did but this causes more work than replacing the string by
jk> foot because i have to find out which way the string was encoded
jk> before i can decode it. For now i just decided its bad luck for
jk> people to use a buggy browser with this application