kelvinwkw
asked on
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("加入 1916;Ĥ 33;账 ;号" );
However it works under Netscape.
Its an ASP page
Thanks =)
Although i've add
<% Session.Codepage = 65001%>
and
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
on every single page
alert("加入
However it works under Netscape.
Its an ASP page
Thanks =)
alert(String.fromCharCode( 20837,2191 6,29233,36 134,21495) );
ASKER
no luck for IE =(
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(charac terCode)
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,11 1,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.
<--
...
JavaScript 1.2 introduced
String.fromCharCode(charac
to find the character from its ascii/iso/unicode, as in
alert(String.fromCharCode(
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(
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.
<--
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...
ASKER
加入喜&# 29233;$ 134;ࡥ 5;
These are the characters that will be displayed
These are the characters that will be displayed
ASKER
oh my god ..
cant display chinese
cant display chinese
<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...
You should see "abc", then "def"
<script type="text/javascript">
alert(String.fromCharCode(
alert("\u0064\u0065\u0066"
</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...
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?
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?
ASKER
<html>
<body>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<input type="button" value="加入 1916;Ĥ 33;账 ;号" onclick="alert('肯&# 23450; 152;ࠣ 7;此 账&# 21495; 527;?');"/ >
</body>
</html>
Please try this on ur browser =)
<body>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<input type="button" value="加入
</body>
</html>
Please try this on ur browser =)
ASKER
<html>
<body>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<input type="button" value="加入 1916;Ĥ 33;账 ;号" onclick="alert('加&# 20837; 916;୫ 3;账 号') ;"/>
</body>
</html>
I think try this better
<body>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<input type="button" value="加入
</body>
</html>
I think try this better
Its working for me. I think you need to install the Japanise font for displaying it properly.
ASKER
Those r chinese word =(
alert('肯定 1152;Ð 37;此 ;账& #21495; 1527;?');
Is that correct? I can't find a reference to if that is correct or not. But this should work:
alert(String.fromCharCode( 32943,2345 0,21152,20 837,27492; 36134,2149 5;21527);
Or you can use this:
alert("\u80af\u5b9a\u52a0\ u5165\u6b6 4\u8d26\u5 3f7\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="abc 00;e& #102;"
document.write(abcdef);
var x=String.fromCharCode(3294 3,23450,21 152,20837, 27492,3613 4,21495,21 527);
var y="\u80af\u5b9a\u52a0\u516 5\u6b64\u8 d26\u53f7\ u5417"
alert(x);
alert(y);
</script>
</script>
Is that correct? I can't find a reference to if that is correct or not. But this should work:
alert(String.fromCharCode(
Or you can use this:
alert("\u80af\u5b9a\u52a0\
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="abc
document.write(abcdef);
var x=String.fromCharCode(3294
var y="\u80af\u5b9a\u52a0\u516
alert(x);
alert(y);
</script>
</script>
ASKER
abcdef plus
Popups with empty boxes...
But i need it to be display as chinese characters
Popups with empty boxes...
But i need it to be display as chinese characters
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
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
ASKER
Im with IE 6.0 =)
Will refers to the info soon..
Lunch time
Will refers to the info soon..
Lunch time
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.
That's all for now. Search Google for: chinese unicode fonts
etc.
I'm too beat to continue. Talk to you later.
ASKER
http://www.geocities.com/kelvinwkw/imageIE.JPG
http://www.geocities.com/kelvinwkw/imageNet.JPG
Have a look and you'll understand
http://www.geocities.com/kelvinwkw/imageNet.JPG
Have a look and you'll understand
What operating system is it? XP? 98? 2k?
ASKER
xp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.