471,075 Members | 1,253 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,075 software developers and data experts.

charset in window created from javascript

Hello

I open a window from JavaScript with w=window.open,
write content with w.document.open,w.document.write,
w.document.close. I specified charset with
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-2">
but did not help much.
In Internet Explorer w.document.charset="ISO-8559-2"
after w.document.open solved the problem, but with Mozilla
this do not work. There is a w.document.characterSet, but
this is read only. Mozilla seems forcing UTF-8 - is there a way
to change this?
Jul 23 '05 #1
5 6264


Lőrinczy Zsigmond wrote:

I open a window from JavaScript with w=window.open,
write content with w.document.open,w.document.write,
w.document.close. I specified charset with
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-2">
but did not help much.
In Internet Explorer w.document.charset="ISO-8559-2"
after w.document.open solved the problem, but with Mozilla
this do not work. There is a w.document.characterSet, but
this is read only. Mozilla seems forcing UTF-8 - is there a way
to change this?


I am not sure I understand the problem, once you are having script
writing to the page you are using JavaScript strings and these allow you
to use all Unicode characters directly or encoded
(String.fromCharCode(unicode), '\udddd')) so character set problems
shouldn't arise.
For instance the following writes the Euro symbol and a German umlaut to
the window just fine with Netscape 7.2:

var text = 'Der Preis ist 200€ über dem Limit.';
var win = window.open('', 'jsWin',
'width=300,height=300,scrollbars,resizable');
win.document.open();
win.document.write('<p>' + text + '<\/p>');
win.document.close();

In what way do you think Mozilla is "forcing UTF-8", how do figure that?

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Martin Honnen wrote:


Lőrinczy Zsigmond wrote:

I open a window from JavaScript with w=window.open,
write content with w.document.open,w.document.write,
w.document.close. I specified charset with
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-2">
but did not help much.
In Internet Explorer w.document.charset="ISO-8559-2"
after w.document.open solved the problem, but with Mozilla
this do not work. There is a w.document.characterSet, but
this is read only. Mozilla seems forcing UTF-8 - is there a way
to change this?

I am not sure I understand the problem, once you are having script
writing to the page you are using JavaScript strings and these allow you
to use all Unicode characters directly or encoded
(String.fromCharCode(unicode), '\udddd')) so character set problems
shouldn't arise.
For instance the following writes the Euro symbol and a German umlaut to
the window just fine with Netscape 7.2:

var text = 'Der Preis ist 200€ über dem Limit.';
var win = window.open('', 'jsWin',
'width=300,height=300,scrollbars,resizable');
win.document.open();
win.document.write('<p>' + text + '<\/p>');
win.document.close();

In what way do you think Mozilla is "forcing UTF-8", how do figure that?


Well if I w.document.write ("Név") (three bytes) and I see "NĂ*v" in
Page Source (four bytes).
Jul 23 '05 #3


Lőrinczy Zsigmond wrote:
Martin Honnen wrote:

In what way do you think Mozilla is "forcing UTF-8", how do figure that?

Well if I w.document.write ("Név") (three bytes) and I see "NĂ*v" in
Page Source (four bytes).


I see, so your problem is not with the rendered HTML in the browser
window but with the rendered source in view source? Or is there a
problem with the rendered HTML too?
I am going to search bugzilla on the view source problem, maybe that is
a known problem.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #4


Martin Honnen wrote:

I am going to search bugzilla on the view source problem, maybe that is
a known problem.


Yes, it is a known problem:
https://bugzilla.mozilla.org/show_bug.cgi?id=161778

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #5
Martin Honnen wrote:


Martin Honnen wrote:

I am going to search bugzilla on the view source problem, maybe that
is a known problem.

Yes, it is a known problem:
https://bugzilla.mozilla.org/show_bug.cgi?id=161778

Yes it is the same problem. Thank you!
Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Kai Grossjohann | last post: by
10 posts views Thread by Marshall Dudley | last post: by
32 posts views Thread by Eli | last post: by
6 posts views Thread by news.versatel.de | last post: by
4 posts views Thread by Todd | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.