SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using a different character set inside a JavaScript file

    Inside my .js file I have some text in Hebrew. However, whenever it is written to the document or displayed in any way (alert() for example), it is shown as gibberish.

    Any idea how to fix this?

    Thanks.

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    HTML Code:
    <script type="text/javascript" src="/script.js" charset="utf-8"></script>
    Replace the charset I posted (utf-8) with the one for hebrew.

  3. #3
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, thanks... that works with my test pages, but when I try to use it in my real application (which is XUL-based) nothing changes.

    Here is how I use the script:
    Code:
      <?xml version="1.0" encoding="Windows-1255"?>
      <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
      <?xml-stylesheet href="common.css" type="text/css"?>
      
      <window id="frame" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
      <script type="text/javascript" src="common.js" charset="windows-1255" />
      ...
      </window>
    And I send this header along with the XUL page:
    Code:
    Content-type: application/vnd.mozilla.xul+xml; charset=windows-1255

  4. #4
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I add the HTML namespace and use the <html:script /> tag instead, the Hebrew text is displayed correctly... the only problem is that the script seems to get included twice - the first load gives the right text but the second load gives the 'bad' text. Maybe charset is the wrong attribute for the XUL <script /> tag?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •