UTF-8 JavaScript files



I'm having a problem with a UTF-8 HTML page containing a
<script> tag that calls in a JavaScript file that is also
encoded in UTF-8.

The JavaScript program, among other things, contains a string
literal, which contains an umlaut, and dynamically puts the
string into an HTML tag. But the umlaut is not displayed
properly and displays as a little square box instead. What could
be the cause of this problem?

Am I right in assuming that a JavaScript file inserted by means
of the <script> tag is interpreted as being encoded in the same
character set as the HTML page itself? If so, then I have to
search for the error elsewhere.

I haven't gotten to any more thorough analysis yet. Thought I
should ask here first, just in case there are a few well-known
potential causes.

Hans-Georg
.



Relevant Pages

  • Re: Code Review: Ajax function with javascript on loaded page enabled
    ... That one along with another "<script" are quoted. ... Not from an HTML parser's point of view. ... a start tag for a script element ... When this simple HTML parser passes the string "\nvar foo = '" to the ...
    (comp.lang.javascript)
  • Re: encoding of scripts
    ... is not valid HTML - the fact that there is an end script tag in quotes ... causes the parser to stop recognising the script. ... The fact that there is an end tag causes that. ... By HTML 4.01 rules, yes. ...
    (comp.infosystems.www.authoring.html)
  • Re: UTF-8 JavaScript files
    ... The JavaScript program, among other things, contains a string ... string into an HTML tag. ... Am I right in assuming that a JavaScript file inserted by means ... character set as the HTML page itself? ...
    (comp.lang.javascript)
  • Re: UTF-8 JavaScript files
    ... puts the string into an HTML tag. ... Am I right in assuming that a JavaScript file inserted by ... means of the <script> tag is interpreted as being encoded ... Though I would expect the above description to assert that you have examined the HTML traffic and verified first that the javascript is being served to appropriate content type headers (either asserting UTF-8, or at least not contradicting it), and second, that the actual bytes being sent includes the correct sequence of bytes for the UTF-8 encoding of the offending character. ...
    (comp.lang.javascript)
  • Re: Flyout Menus from Dynamic Drive...
    ... Have you contact the author of the script? ... Add the below script in the of MyframeOne, ... do they mean the body of the HTML page ... > inside the tag for MyFrameOne?) ...
    (microsoft.public.frontpage.client)