Javascript utf-8 alert in IE

I am facing a problem whereby IE does not alert these utf-8 character probably.

Although i've add
<% Session.Codepage = 65001%>
and
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

on every single page

alert("&#21152;&#20837;&#21916;&#29233;&#36134;&#21495;");

However it works under Netscape.

Its an ASP page

Thanks =)
LVL 11
kelvinwkwAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
callrsConnect With a Mentor Commented:
http://support.microsoft.com/default.aspx?scid=kb;en-us;211147     INFO: Internet Explorer Script Prompts and MBCS/Unicode
"On systems running English language versions of Windows 95, Windows 98, and Windows NT...cannot handle the display and input of text in multibyte character systems, such as Japanese and Chinese....The functions alert(), prompt(), confirm(), MsgBox, and InputBox all ultimately call Win32 functions such as MessageBox(), which can only display text for the default system locale....

"This problem does not affect localized versions of Windows systems, as long as the specified language is used. In other words, Japanese text displays fine in an alert box on systems running Japanese Windows, and the IME activates for prompt dialogs. Additionally, users of Windows 2000 Multilingual User Interface Edition (MUI) can bypass this problem by installing support for the appropriate language. "

http://en.wikipedia.org/wiki/Criticisms_of_Internet_Explorer GS:alert box IE unicode     Criticism of Internet Explorer - Wikipedia, the free encyclopedia
"Internet Explorer supports the Unicode standard for multilingual text, and is therefore theoretically capable of displaying any character which is present in an installed font. In practice, Internet Explorer does not automatically choose fonts for blocks of mixed Unicode text. Characters can end up displayed as blank squares or question marks.

"Web designers must guess which appropriate fonts may be present on users' computers, and manually specify them for every change of Unicode block. In contrast, most other browsers do this automatically.

"Workarounds
To get around these problems, many web designers build websites compliant to W3C standards, and then implement workarounds or hacks to account for Internet Explorer's rendering inadequacies, or to hide advanced website features from IE. The CSS hacks are often very complicated, as they need to deal with different versions of IE on different platforms..."

----------
So, its an MS Internet Explorer BUG! Now it's not so simple as we thought it would be...but you now have the answer as to WHY you see blocks in IE but not in Netscape. You can take it from there by reading those articles & Googling for e.g.: alert box IE unicode

Here's one of 8 workarounds mentioned in the Wikipedia:
http://dean.edwards.name/IE7/           /IE7/
"IE7 is a JavaScript library to make IE behave like a standards-compliant browser. It fixes many CSS issues and makes transparent PNG work correctly under IE5 and IE6"
0
 
callrsCommented:
alert(String.fromCharCode(20837,21916,29233,36134,21495));
0
 
kelvinwkwAuthor Commented:
no luck for IE =(
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
callrsCommented:
Quote: www.faqts.com/knowledge_base/view.phtml/aid/1621 GS:javascript unicode alert     FAQTs - Knowledge Base - View Entry - How do I get the character from the (ascii/iso/uni) char code? -->
...
JavaScript 1.2 introduced
  String.fromCharCode(characterCode)
to find the character from its ascii/iso/unicode, as in
  alert(String.fromCharCode(169))
so if you script for version 4+ browsers you don't need to custom
function given at the beginning.
You can even pass in a list of char codes e.g.
  alert(String.fromCharCode(75,105,98,111,108,111,103,121))

With JavaScript 1.3 you can also use unicode escape sequences of the
form
  '\uDDDD'
where
  DDDD
is the 4 digit hexadecimal char code value e.g.
  alert('\u00A9')
will also show the copyright symbol.
<--
0
 
callrsCommented:
kelvinwkw, I'm using IE, and I got it to work...Not the characters you want printed since I dont have the fonts you have, but the alert & String.fromCharCode DO work together...
0
 
kelvinwkwAuthor Commented:
&#21152;&#20837;&#21916;&#29233;&#36134;&#21495;

These are the characters that will be displayed

0
 
kelvinwkwAuthor Commented:
oh my god ..
cant display chinese
0
 
callrsCommented:
<html>
You should see "abc", then "def"
<script type="text/javascript">
alert(String.fromCharCode(0x61,0x62,0x63)); // alert abc
alert("\u0064\u0065\u0066"); // alert def
</script>
</html>

Copy & paste that into a notepad file, save the file as "c:\temp\test.htm" (be sure to put quotes or it may save it as test.htm.txt)
Then open the file in IE by typing: c:\temp\test.htm
You'll see 2 alets popup up

Now, you can substitute your unicode numbers the alert statements....if the above works but your characters don't, THEN YOU LIKELY NEED TO INSTALL THE FONT(S)...

Let me know if my example works (abc, def) in your IE or not, etc. It works on mine...
0
 
callrsCommented:
http://home.att.net/~jameskass/utf8ornot.htm GS:utf-8 ie 5     UTF-8 Encoding / Netscape & Internet Explorer
www.alanwood.net/unicode/explorer.html GS:utf-8 ie 5.5     Setting up Windows Internet Explorer 5, 5.5 and 6 for Multilingual and Unicode Support

What version of IE are you using?
0
 
kelvinwkwAuthor Commented:
<html>
<body>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<input type="button" value="&#21152;&#20837;&#21916;&#29233;&#36134;&#21495;" onclick="alert('&#32943;&#23450;&#21152;&#20837;&#27492;&#36134;&#21495;&#21527;?');"/>
</body>

</html>

Please try this on ur browser =)
0
 
kelvinwkwAuthor Commented:
<html>
<body>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<input type="button" value="&#21152;&#20837;&#21916;&#29233;&#36134;&#21495;" onclick="alert('&#21152;&#20837;&#21916;&#29233;&#36134;&#21495;');"/>
</body>

</html>


I think try this better
0
 
gksinghietCommented:
Its working for me. I think you need to install the Japanise font for displaying it properly.
0
 
kelvinwkwAuthor Commented:
Those r chinese word =(

0
 
callrsCommented:
alert('&#32943;&#23450;&#21152;&#20837;&#27492;&#36134;&#21495;&#21527;?');
Is that correct? I can't find a reference to if that is correct or not. But this should work:

alert(String.fromCharCode(32943,23450,21152,20837,27492;36134,21495;21527);
Or you can use this:
alert("\u80af\u5b9a\u52a0\u5165\u6b64\u8d26\u53f7\u5417");
but the way you got it -- it's meant for HTML and the document.write command which writes to the HTML document in your browser: the "&...;" is for HTML (see code below)

Copy & paste this into a new .htm file, and open it in IE. LET ME KNOW WHAT YOU SEE IN THE ALERT BOXES THEN. Thanks
<script type="text/javascript">
var abcdef="&#97;&#98;&#99;&#100;&#101;&#102;"
document.write(abcdef);
var x=String.fromCharCode(32943,23450,21152,20837,27492,36134,21495,21527);
var y="\u80af\u5b9a\u52a0\u5165\u6b64\u8d26\u53f7\u5417"
alert(x);
alert(y);
</script>
</script>
0
 
kelvinwkwAuthor Commented:
abcdef plus
Popups with empty boxes...
But i need it to be display as chinese characters
0
 
callrsCommented:
Then look at the last two links I gave you; search on Google for more if those links are not good enough. You apparently need to install some chinese fonts. Have you installed them?
If you have IE v5 or v5.5, there might be some problems. You havent told me yet what version of IE you are using. Are you using v 6.0?

Be sure to use either one of the two unicode syntax I've given you. Your other syntax simply wont work....


To test if you have the fonts installed: go to
http://www.macchiato.com/unicode/chart/     JavaScript Unicode Charts
And type in a unicode number and then hit Find.

Here's a link for display problems: http://www.unicode.org/help/display_problems.html
0
 
kelvinwkwAuthor Commented:
Im with IE 6.0 =)
Will refers to the info soon..
Lunch time
0
 
callrsCommented:
http://www.thdl.org/tools/chinese.html "To work with Chinese characters beyond plane 0 of the Unicode standard (Unicode CJK Extension A and B*) it is also necessary to install Microsoft's GB18030 support package**  for Windows 2000 & XP. This package includes a large (12 MB) Chinese font (SimSun18030.ttc)." http://www.microsoft.com/downloads/details.aspx?FamilyID=fc02e2e3-14bb-46c1-afee-3732d6249647&DisplayLang=en

That's all for now. Search Google for: chinese unicode fonts
etc.
I'm too beat to continue. Talk to you later.
0
 
kelvinwkwAuthor Commented:
0
 
callrsCommented:
What operating system is it? XP? 98? 2k?
0
 
kelvinwkwAuthor Commented:
xp
0
All Courses

From novice to tech pro — start learning today.