blcott
asked on
Chinese characters appearing as boxes in Javascript alert boxes
I am trying to get chinese characters to display in my alert message box using javascript. On my XP machine everything displays properly, Chinese in the html and in the javascript dialog boxes. On my windows 2000 machine, the chinese characters in the html is displaying properly, but the chinese characters in the javascript dialog boxes appear as "boxes".
My HTML page is set to use charset="utf-8". The chinese characters are displaying perfectly on the web page itself.
Does this have something to do with the browser and the Javascript version it supports?
sample:
<script LANGUAGE="JavaScript" TYPE="text/javascript">
alert("此测 5797;Ŋ 21;够 ;检& #27979; 4394;Í 51;和 ;夸& #22823; 0340;Þ 38;答 ;。 \n\n 非真实&# 31572; 696;ᦁ 2;则 你&# 30340; 979;෻ 7;结 果&# 26080; 928;");
</script>
My HTML page is set to use charset="utf-8". The chinese characters are displaying perfectly on the web page itself.
Does this have something to do with the browser and the Javascript version it supports?
sample:
<script LANGUAGE="JavaScript" TYPE="text/javascript">
alert("此测
</script>
try using that javascript above to display you characters on your page. that should work fine.
An interesting problem. I have a very recent version of IE on my Windows 2000 machine and have the same problem.
Accorsing to IBM's globalisation tips alert(), confirm(), and prompt() functions in some browsers are just not capable of showing utf-8 encoded characters.
http://publib.boulder.ibm.com/infocenter/wchelp/v5r6/index.jsp?topic=/com.ibm.commerce.developer.doc/refs/rgbtips.htm
I notice there is no problem with Firefox on the same machine. I have IE 6.0.2800.1106 here. I can check later what version of IE is on my XP box.
Accorsing to IBM's globalisation tips alert(), confirm(), and prompt() functions in some browsers are just not capable of showing utf-8 encoded characters.
http://publib.boulder.ibm.com/infocenter/wchelp/v5r6/index.jsp?topic=/com.ibm.commerce.developer.doc/refs/rgbtips.htm
I notice there is no problem with Firefox on the same machine. I have IE 6.0.2800.1106 here. I can check later what version of IE is on my XP box.
ASKER
maclema,
Taking those decimal characters in my example above, as you suggest, does not work. The js dialog displays exactly that, the decimal characters.
blcott
Taking those decimal characters in my example above, as you suggest, does not work. The js dialog displays exactly that, the decimal characters.
blcott
try
var temp = document.createElement('di v')
temp.innerHTML = "此测试& #33021; 2815;Č 16;测 ;虚& #20551; 1644;ä 40;大 ;的& #22238; 1572;z 90; \n\n 非真实&# 31572; 696;ᦁ 2;则 你&# 30340; 979;෻ 7;结 果&# 26080; 928;"
alert(temp.innerHTML)
var temp = document.createElement('di
temp.innerHTML = "此测试&
alert(temp.innerHTML)
could it be that your win2000 simply has not a unicode font installed? i also know that TAHOMA.TTF on win2000 contains quite less characters than the one coming with XP. this font file is VERY HUGE and since the display boxes from MSIE dont really rely on the capability of html compatibility but instead on the ones of the system itself, i guess its simply an issue of the regional settings.
try microsoft.com for downloading the most recent unicode TAHOMA.TTF (or copy it from XP, then go into the fonts folder on 2K and select "install font"). im sure thats the "problem"
try microsoft.com for downloading the most recent unicode TAHOMA.TTF (or copy it from XP, then go into the fonts folder on 2K and select "install font"). im sure thats the "problem"
ASKER
dynamicrevolutions and AmigoJack
None of your solutions work. Again on w2k with IE 6.0 the page displays the simplified characters fine but the javascript dialog box contains "boxes". I have FireFox 5.0 on the same machine and everthing displays properly, characters on page and characters in js dialog box.
This is the only question I have ever posted on this site that there doesn't seem to be anyone with a solution. That is amazing!
None of your solutions work. Again on w2k with IE 6.0 the page displays the simplified characters fine but the javascript dialog box contains "boxes". I have FireFox 5.0 on the same machine and everthing displays properly, characters on page and characters in js dialog box.
This is the only question I have ever posted on this site that there doesn't seem to be anyone with a solution. That is amazing!
did you check start -> control panel -> regional settings -> languages -> additional language support (complex letters, right to left, east asian)? firefox displays messageboxes itself (on its own support), while MSIE uses standard windows functions instead - so it must be a problem dealing with win2k
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I have had the same issue. I had the language pack installed (simplified Chinese language pack) from Microsoft's site. The characters on the web page would look fine (using unicode) characters, but when the same characters were put in an alert box it would just display sqaures. I fixed this by installing the "East Asian languages" in windows. For Windows XP, open the control panel and double click on "regional and language options" Then on the "language" tab click the check box that is labeled "Install files for East Asian Languages". That seemed to fix it for me.
Thanks,
Jeff Beard-Shouse
Business Software Group at Motorola
Thanks,
Jeff Beard-Shouse
Business Software Group at Motorola
ASKER