Character encoding after window.open()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stup
    New Member
    • Mar 2007
    • 2

    #1

    Character encoding after window.open()

    Hi!

    I have a small javascript snippet that does the following:

    Code:
    // an entire html document is in here
    data = "\u003c!DOCTYPE html PUBLIC \u0022-//W3C//DTD XHTML 1.1 Strict//EN\u0022\n  ...."; 
    
    newwin = window.open("", "outputwin", "");
    newwin.document.write(data);
    newwin.document.close();
    Now, in the data variable, the character encoding is set to be UTF-8 using a meta http-equiv tag. Same for the page that contains this script.

    When I look at the character encoding in the Firefox (2.0.0.3) "View Page Info" dialogue box, it tells me the following:

    The original page has an Encoding of UTF-8 and the Content-type is text/html; charset=utf-8

    The new page, however, has an Encoding of ISO-8859-1 but the Content-type is shown as text/html; charset=utf-8.

    This is the case when there are non-ISO-8895-1 characters present although they are correctly displayed.

    So...

    * Is this something to be worried about?

    * Is this something I can address in the javascript? (is there an optional argument to document.open that specifies the charset? I can't find one!)

    * Is this instead a Firefox bug?

    All thoughts and ideas appreciated.
  • stup
    New Member
    • Mar 2007
    • 2

    #2
    Follow-up: saving the source of the file in Firefox and looking at it in a hexeditor, it looks like it's actually UTF-16/UCS-2.

    Even more strange?

    Comment

    • asc99c
      New Member
      • Mar 2008
      • 1

      #3
      Sorry to jump into your thread, but hey, free bump back up to the top!

      I'm having the same problem but trying to use IBM850 character set. On a normal page, I send the following line in the header information (i.e. before the html tag):
      Content-type: text/html; charset=IBM850

      I can't do this when using Javascripts window.open. Firefox shows the encoding of a javascript popup window to be UTF-8. I've already tried adding the following line inside the HTML that is written to the javascript window:
      <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=IBM850" >

      This has no effect though. Any non-ASCII IBM850 characters are displayed wrongly in the popup window.

      Comment

      Working...