Microsoft KB Archive/239948

= FIX: Unicode .js File Included from SCRIPT Tag Generates Script Error =

Article ID: 239948

Article Last Modified on 10/16/2002

-

APPLIES TO


 * Microsoft Internet Explorer 5.0

-



This article was previously published under Q239948



SYMPTOMS
Internet Explorer reports an "Invalid character" error when a Unicode .js file is included with the SCRIPT tag, for example:  If the script debugger is enabled, it reports that the first two characters in the .js file (the Unicode Byte Order Mark, or BOM) are the source of the problem.

Another closely associated problem occurs if the Byte Order Mark is removed from a Unicode format .js file and the file contains Unicode characters. When the .js file is included during page rendering by Internet Explorer, Unicode characters in the .js file are interpreted as simple ASCII and cause either a script error, as above, or the display of garbage characters. Similarly, removing the BOM from a UTF-8 encoded file containing non-ASCII Unicode characters results in garbage characters being displayed on the rendered Web page.

Note that in the Internet Explorer Advanced dialog box (from the Tools menu, select Internet Options), the option Disable script debugging must be cleared or the option Display a notification about every script error must be selected in order to receive a detailed error message for this problem. If these two options are not set correctly, the Internet Explorer status bar indicates that there are errors on the page. The page loads, but the .js file does not.



RESOLUTION
It is possible to work around the problem, in most cases, by embedding Unicode escape sequences in the .js file that is saved in ASCII. For instance, the following JScript statement may be used in an ASCII .js file to specify the Hiragana character NO. var s = String("Hiragana NO = \u306E"); When the ASCII .js file is loaded from the SCRIPT tag there is, of course, no Unicode Byte Order Mark, and the \uXXXX escapes are converted to proper Unicode characters that appear on a Web page.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Internet Explorer 5.5 and Internet Explorer 5.01 on Windows 2000.

Additional query words: unicode javascript include files

Keywords: kbbug kbfix kbie501fix kbintl kbintldev kbie550fix KB239948

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.