From: Martin Honnen on 6 Jul 2010 09:14 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/
From: Laser Lips on 6 Jul 2010 09:21 On Jul 6, 2:14 pm, Martin Honnen <mahotr...(a)yahoo.de> 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
From: Martin Honnen on 6 Jul 2010 09:31 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/
From: Laser Lips on 6 Jul 2010 10:04
On Jul 6, 2:31Â pm, Martin Honnen <mahotr...(a)yahoo.de> 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 |