Strange javascript decoding behavior in IE
Posted
by Yoni
on Stack Overflow
See other posts from Stack Overflow
or by Yoni
Published on 2010-03-21T14:45:41Z
Indexed on
2010/03/21
14:51 UTC
Read the original article
Hit count: 305
I run the following html snippet in IE8 and IE7 with non-English characters (we tried both Hebrew and Chinese), and the second link never works properly.
The displayed text in the alert box is mangled.
This occurs in IE8 and IE7, but not in firefox. It is not dependent on Windows's regional settings.
Here is the html snippet (html header and footer omitted for brevity, the content-type is "text/html; charset=utf-8", and so is the response header):
<p>
<a href="javascript:alert('ab????ab')">link with English and Hebrew text</a>
<a href="javascript:alert('ab%D7%A9%D7%9C%D7%95%D7%9Dab')">same text, url encoded</a>
</p>
Here is the alert box that pops up when clicking the second link:
I know that the string for "????" is encoded as 8 bytes in utf-8, thus there are 8 %NN items, and there are also 8 weird characters in the alert box. The problem is, how can I make IE recognize that this is utf-8 encoding text, like firefox does?
© Stack Overflow or respective owner