javascript charset <> page charset

Discussion in 'Javascript' started by optimistx, Aug 14, 2008.

  1. optimistx

    optimistx Guest

    I try to develope a bookmarklet in javascript. The charset of the
    bookmarklet is UTF-8, but it is supposed to work within pages, whose
    character set is not UTF-8, but e.g. ISO-8859-1 or WINDOWS-1252. The
    bookmarklet loads other javascript files with the attribute charset="UTF-8".

    Mostly everything works nicely, but at least alert-boxes seem to show
    different characters depending on the browser (Firefox 3 , Opera 9.02, ie6
    has been compared this far: Opera uses the page character set, ff and ie
    js-charset.).

    'Feature testing' is a fascinating idea, but how can it be used in this case
    or otherwise solv this problem?
     
    optimistx, Aug 14, 2008
    #1
    1. Advertising

  2. optimistx wrote:

    > I try to develope a bookmarklet in javascript. The charset of the
    > bookmarklet is UTF-8, but it is supposed to work within pages, whose
    > character set is not UTF-8, but e.g. ISO-8859-1 or WINDOWS-1252.  The
    > bookmarklet loads other javascript files with the attribute charset="UTF-8".
    >
    > Mostly everything works nicely, but at least alert-boxes seem to show
    > different characters depending on the browser (Firefox 3 , Opera 9.02, ie6
    > has been compared this far: Opera uses the page character set, ff and ie
    > js-charset.).


    Two ideas: It might be an issue for Opera whether the remote js-file
    was saved under UTF-8 or not. It might also matter whether that file
    has a charset-header from itself.

    When the 'charset'-argument is used for an external script-call, then
    this should only indicate how the main caller file will (try to) treat
    non-ASCII characters in the remote file (except when UTF-7). And this
    should normally stand apart from the encoding that is used in the
    caller file.

    Hope this helps,

    --
    Bart
     
    Bart Van der Donck, Aug 14, 2008
    #2
    1. Advertising

  3. optimistx

    optimistx Guest

    Bart Van der Donck wrote:

    > Two ideas: It might be an issue for Opera whether the remote js-file
    > was saved under UTF-8 or not. It might also matter whether that file
    > has a charset-header from itself.
    >
    > When the 'charset'-argument is used for an external script-call, then
    > this should only indicate how the main caller file will (try to) treat
    > non-ASCII characters in the remote file (except when UTF-7). And this
    > should normally stand apart from the encoding that is used in the
    > caller file.
    >
    > Hope this helps,


    Thanks, your advice helped. After all, there was no discrepancy between
    browsers. When the original files really have the character sets which their
    http-headers claim they have, and the files are without any 'BOM'- marks,
    then the Apache-servers and browsers do their work as expected. The final
    alertbox is shown correctly in 3 browsers at least provided that the
    entities like &auml; are programmatically replaced by appropriate character
    codes.
     
    optimistx, Aug 15, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Efy.
    Replies:
    2
    Views:
    1,119
  2. Sasha Shevelev

    Re: Displaying Charset windows-1251

    Sasha Shevelev, Jul 2, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    3,171
    Sasha Shevelev
    Jul 2, 2003
  3. Fritz Bayer
    Replies:
    1
    Views:
    4,334
    Wibble
    May 30, 2005
  4. =?Utf-8?B?am9l?=

    how to change page-level charset to big5

    =?Utf-8?B?am9l?=, Oct 25, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    322
    =?Utf-8?B?am9l?=
    Oct 25, 2006
  5. Lõrinczy Zsigmond

    charset in window created from javascript

    Lõrinczy Zsigmond, Dec 4, 2004, in forum: Javascript
    Replies:
    4
    Views:
    672
    LÅ‘rinczy Zsigmond
    Dec 5, 2004
Loading...

Share This Page