charset in window created from javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lõrinczy Zsigmond

    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.wri te,
    w.document.clos e. 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.char set="ISO-8559-2"
    after w.document.open solved the problem, but with Mozilla
    this do not work. There is a w.document.char acterSet, but
    this is read only. Mozilla seems forcing UTF-8 - is there a way
    to change this?
  • Martin Honnen

    #2
    Re: charset in window created from javascript



    Lőrinczy Zsigmond wrote:

    [color=blue]
    > I open a window from JavaScript with w=window.open,
    > write content with w.document.open ,w.document.wri te,
    > w.document.clos e. 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.char set="ISO-8559-2"
    > after w.document.open solved the problem, but with Mozilla
    > this do not work. There is a w.document.char acterSet, but
    > this is read only. Mozilla seems forcing UTF-8 - is there a way
    > to change this?[/color]

    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.fromCha rCode(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,heig ht=300,scrollba rs,resizable');
    win.document.op en();
    win.document.wr ite('<p>' + text + '<\/p>');
    win.document.cl ose();

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

    --

    Martin Honnen

    Comment

    • LÅ‘rinczy Zsigmond

      #3
      Re: charset in window created from javascript

      Martin Honnen wrote:
      [color=blue]
      >
      >
      > Lőrinczy Zsigmond wrote:
      >
      >[color=green]
      >> I open a window from JavaScript with w=window.open,
      >> write content with w.document.open ,w.document.wri te,
      >> w.document.clos e. 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.char set="ISO-8559-2"
      >> after w.document.open solved the problem, but with Mozilla
      >> this do not work. There is a w.document.char acterSet, but
      >> this is read only. Mozilla seems forcing UTF-8 - is there a way
      >> to change this?[/color]
      >
      >
      > 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.fromCha rCode(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,heig ht=300,scrollba rs,resizable');
      > win.document.op en();
      > win.document.wr ite('<p>' + text + '<\/p>');
      > win.document.cl ose();
      >
      > In what way do you think Mozilla is "forcing UTF-8", how do figure that?[/color]

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

      Comment

      • Martin Honnen

        #4
        Re: charset in window created from javascript



        Lőrinczy Zsigmond wrote:
        [color=blue]
        > Martin Honnen wrote:[/color]
        [color=blue][color=green]
        >> In what way do you think Mozilla is "forcing UTF-8", how do figure that?[/color]
        >
        >
        > Well if I w.document.writ e ("Név") (three bytes) and I see "NĂŠv" in
        > Page Source (four bytes).[/color]

        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

        Comment

        • Martin Honnen

          #5
          Re: charset in window created from javascript



          Martin Honnen wrote:

          [color=blue]
          > I am going to search bugzilla on the view source problem, maybe that is
          > a known problem.[/color]

          Yes, it is a known problem:


          --

          Martin Honnen

          Comment

          • LÅ‘rinczy Zsigmond

            #6
            Re: charset in window created from javascript

            Martin Honnen wrote:[color=blue]
            >
            >
            > Martin Honnen wrote:
            >
            >[color=green]
            >> I am going to search bugzilla on the view source problem, maybe that
            >> is a known problem.[/color]
            >
            >
            > Yes, it is a known problem:
            > https://bugzilla.mozilla.org/show_bug.cgi?id=161778
            >[/color]
            Yes it is the same problem. Thank you!

            Comment

            Working...