Alerting Chinese characters - can it be done?

L

Laser Lips

Does anyone know if I can print Chinese chracters ?

alert("Çë×¢ÒâÊý¾Ý½«ÒÔ");

Thanks,
Graham
 
M

Martin Honnen

Laser said:
Does anyone know if I can print Chinese chracters ?

alert("请注æ„æ•°æ®å°†ä»¥");

Firefox 3 does render those characters in a alert dialog window on a
German edition of Windows XP Professional. However IE 8 on the same
system only renders square boxes for each character.
Safari and Opera also manage to display those characters in an alert
dialog window.
 
L

Laser Lips

Thanks for the reply. I only need to support IE if anyone has an IE
solution.

Graham
 
L

Laser Lips

If the alert dialog does not show such characters then with IE you could
define your own dialog contents with HTML and show it using showModalDialoghttp://msdn.microsoft.com/en-us/library/ms536759(v=VS.85).aspx


Actually, I necessarily need to alert the characters. I just find
that JavaScript doesn’t seem to be able to handle the characters. I'm
going to be writing them to an element on the page, but I can't seem
to do anything with them once JavaScript as hold of them. They turn
into '?' straight away. Alerting is probably the most basic thing I
could think of doing with them.
If I use document.write it still writes questions marks.

Graham Vincent
 
M

Martin Honnen

Laser said:
Actually, I necessarily need to alert the characters. I just find
that JavaScript doesn’t seem to be able to handle the characters. I'm
going to be writing them to an element on the page, but I can't seem
to do anything with them once JavaScript as hold of them. They turn
into '?' straight away. Alerting is probably the most basic thing I
could think of doing with them.
If I use document.write it still writes questions marks.

Does the browser render Chinese characters correctly when you insert
them statically in your HTML document? Or does that already result in
question marks?

Is a font installed on that system that has glyphs for those characters?

Is the Javascript code embedded inside of an HTML document or is it
inside a separate .js file? What's the encoding of the HTML document or
the .js file?
 
L

Laser Lips

Does the browser render Chinese characters correctly when you insert
them statically in your HTML document? Or does that already result in
question marks?

Is a font installed on that system that has glyphs for those characters?

Is the Javascript code embedded inside of an HTML document or is it
inside a separate .js file? What's the encoding of the HTML document or
the .js file?

Hi Martin, the browser renders the Chi9nese characters correclty if I
put them in statically
The JS file is external. What encoding should I use to save the file?

Thanks
Graham
 
M

Martin Honnen

Laser said:
Hi Martin, the browser renders the Chi9nese characters correclty if I
put them in statically
The JS file is external. What encoding should I use to save the file?

I would use UTF-8. But is more important that the server sends a HTTP
Content-Type header with a charset parameter indicating the encoding,
whatever the encoding is. Or at least use a charset attribute on the
script element to indicate the encoding e.g. if the script file is UTF-8
encodeded then use
<script type="text/javascript" src="file.js" charset="UTF-8"></script>
so that the browser knows the encoding. That way at least document.write
should work without problems. Whether IE allows you to use Chinese
characters in a alert dialog window I am not sure as my test here failed.
 
L

Laser Lips

I would use UTF-8. But is more important that the server sends a HTTP
Content-Type header with a charset parameter indicating the encoding,
whatever the encoding is. Or at least use a charset attribute on the
script element to indicate the encoding e.g. if the script file is UTF-8
encodeded then use
   <script type="text/javascript" src="file.js" charset="UTF-8"></script>
so that the browser knows the encoding. That way at least document.write
should work without problems. Whether IE allows you to use Chinese
characters in a alert dialog window I am not sure as my test here failed.

OK, if I save a HTML file as Unicode and then simply do a
document.write OR an alert("æ„æ•°æ®"); I get Chinese characters.
I think this solves the problem.
One problem remains and that's that the HTML pages and the JavaScript
is created with software called CACHE (Intersystems).
Just need to find out how to tell the write mechanism to use Unicode
and I think the problem is solved.
Cheers for the suggestions.
Graham Vincent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top