Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Alerting Chinese characters - can it be done?

Reply
Thread Tools

Alerting Chinese characters - can it be done?

 
 
Laser Lips
Guest
Posts: n/a
 
      07-06-2010
Does anyone know if I can print Chinese chracters ?

alert("请注意数据将以");

Thanks,
Graham
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      07-06-2010
Laser Lips wrote:
> 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.


--

Martin Honnen
http://msmvps.com/blogs/martin_honnen/
 
Reply With Quote
 
 
 
 
Laser Lips
Guest
Posts: n/a
 
      07-06-2010
Thanks for the reply. I only need to support IE if anyone has an IE
solution.

Graham
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      07-06-2010
Laser Lips wrote:
> Thanks for the reply. I only need to support IE if anyone has an IE
> solution.


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 showModalDialog
http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx


--

Martin Honnen
http://msmvps.com/blogs/martin_honnen/
 
Reply With Quote
 
Laser Lips
Guest
Posts: n/a
 
      07-06-2010
On Jul 6, 12:56*pm, Martin Honnen <(E-Mail Removed)> wrote:
> Laser Lips wrote:
> > Thanks for the reply. *I only need to support IE if anyone has an IE
> > solution.

>
> 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
>
> --
>
> * * * * Martin Honnen
> * * * *http://msmvps.com/blogs/martin_honnen/



Actually, I necessarily need to alert the characters. I just find
that JavaScript doesn抰 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
 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      07-06-2010
Laser Lips wrote:

> Actually, I necessarily need to alert the characters. I just find
> that JavaScript doesn抰 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?


--

Martin Honnen
http://msmvps.com/blogs/martin_honnen/
 
Reply With Quote
 
Laser Lips
Guest
Posts: n/a
 
      07-06-2010
On Jul 6, 2:14*pm, Martin Honnen <(E-Mail Removed)> wrote:
> Laser Lips wrote:
> > 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?
>
> --
>
> * * * * Martin Honnen
> * * * *http://msmvps.com/blogs/martin_honnen/


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

 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      07-06-2010
Laser Lips wrote:

> 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.


--

Martin Honnen
http://msmvps.com/blogs/martin_honnen/
 
Reply With Quote
 
Laser Lips
Guest
Posts: n/a
 
      07-06-2010
On Jul 6, 2:31*pm, Martin Honnen <(E-Mail Removed)> wrote:
> Laser Lips wrote:
> > 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.
>
> --
>
> * * * * Martin Honnen
> * * * *http://msmvps.com/blogs/martin_honnen/


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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RCAP - Common Alerting Protocl for Ruby Farrel Lifson Ruby 1 11-03-2009 08:38 PM
Cisco 500-24 switch alerting on half duplex? edavid3001@gmail.com Cisco 2 11-16-2005 09:34 PM
help-> xslt transformation to pdf (chinese characters changed to # characters) omegaman XML 1 09-21-2004 10:44 PM
Alerting the user from code behind Peter Aitken ASP .Net Building Controls 3 08-02-2004 12:48 PM
Sample for Alerting user susie ASP .Net Web Controls 1 12-03-2003 04:09 AM



Advertisments