UTF-16 + firefox +javascript = null

A

Andrew Poulos

I've written some javascript for a client that uses some in-house tool
to create HTML. They are upgrading their tool so that it handles unicode
(so they can, for example, insert Japanese ideograms directly into the
HTML).

The pages display in IE 7 but Firefox, Chrome etc complain about an
illegal character and then

Error: uncaught exception: [Exception... "Component returned failure
code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIDOMLocation.replace]"
nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)" location: "JS frame ::
file:///C:/Users/Andrew/Desktop/Project/Standalone/content/index.htm ::
anonymous :: line 44" data: no]

and no javascript runs.

When I build the pages from scratch they display.

When I examine their pages they are encoded in UTF-16 with Unix style
line ending.

I manually changed the encoding to UTF-8 but it made no difference.

If I comment out the javascript the page displays fine.

I'm kind of lost with unicode. Is their something I can tell their
developers to stop them killing my javascript?

Andrew Poulos
 
B

Bart Van der Donck

Andrew said:
I've written some javascript for a client that uses some in-house tool
to create HTML. They are upgrading their tool so that it handles unicode
(so they can, for example, insert Japanese ideograms directly into the
HTML).

The pages display in IE 7 but Firefox, Chrome etc complain about an
illegal character and then

Error: uncaught exception: [Exception... "Component returned failure
code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIDOMLocation.replace]"
nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)"  location: "JS frame ::
file:///C:/Users/Andrew/Desktop/Project/Standalone/content/index.htm ::
anonymous :: line 44"  data: no]

and no javascript runs.

When I build the pages from scratch they display.

When I examine their pages they are encoded in UTF-16 with Unix style
line ending.

I manually changed the encoding to UTF-8 but it made no difference.

If I comment out the javascript the page displays fine.

I'm kind of lost with unicode. Is their something I can tell their
developers to stop them killing my javascript?

Welcome to Unicode! :)
It's difficult to say anything concrete without being able to look at
the code. My first idea is that some byte ranges cannot be recognized
because browsers can use various UTF-16 character tables (more vs.
less extended, esp. in the higher code points). Does it fail at the
first Unicoded char that it meets ?

Here are some basic thoughts:
- Definitely go for UTF-8, not UTF-16.
- Make sure that the HTTP-header is correct (Content-Type: text/html;
charset=utf-8).
- The server-script must send data that has been correctly converted
into an Unicode set (sounds easy, I know...)
- In HTML source code, add a meta-tag in the header <meta http-
equiv="Content-Type" content="text/html; charset=UTF-8">.
- A Unix style line-ending should *normally* be okay; better is to use
\r\n anyhow.

I understand the Unicode characters reside in javascript only. You
could ask their IT guys to send \uXXXX. NS_ERROR_FILE_NOT_FOUND seems
to indicate a 404 error -> maybe you are using Unicode characters in
file names ? (=definitely to avoid)

Hope this helps,
 
A

Andrew Poulos

Bart said:
Andrew said:
I've written some javascript for a client that uses some in-house tool
to create HTML. They are upgrading their tool so that it handles unicode
(so they can, for example, insert Japanese ideograms directly into the
HTML).

The pages display in IE 7 but Firefox, Chrome etc complain about an
illegal character and then

Error: uncaught exception: [Exception... "Component returned failure
code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIDOMLocation.replace]"
nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)" location: "JS frame ::
file:///C:/Users/Andrew/Desktop/Project/Standalone/content/index.htm ::
anonymous :: line 44" data: no]

and no javascript runs.

When I build the pages from scratch they display.

When I examine their pages they are encoded in UTF-16 with Unix style
line ending.

I manually changed the encoding to UTF-8 but it made no difference.

If I comment out the javascript the page displays fine.

I'm kind of lost with unicode. Is their something I can tell their
developers to stop them killing my javascript?

Welcome to Unicode! :)
It's difficult to say anything concrete without being able to look at
the code. My first idea is that some byte ranges cannot be recognized
because browsers can use various UTF-16 character tables (more vs.
less extended, esp. in the higher code points). Does it fail at the
first Unicoded char that it meets ?

Here are some basic thoughts:
- Definitely go for UTF-8, not UTF-16.
- Make sure that the HTTP-header is correct (Content-Type: text/html;
charset=utf-8).
- The server-script must send data that has been correctly converted
into an Unicode set (sounds easy, I know...)
- In HTML source code, add a meta-tag in the header <meta http-
equiv="Content-Type" content="text/html; charset=UTF-8">.
- A Unix style line-ending should *normally* be okay; better is to use
\r\n anyhow.

I understand the Unicode characters reside in javascript only. You
could ask their IT guys to send \uXXXX. NS_ERROR_FILE_NOT_FOUND seems
to indicate a 404 error -> maybe you are using Unicode characters in
file names ? (=definitely to avoid)

I think I found the issue. The files they produce are UTF-16. My
javascript files are UTF-8. When Firefox goes to load my files into a
UTF-16 web page it converts them from UTF-8 to 16 and so it appears that
all the characters go awry.

I'll make sure they use only UTF-8. Thank you for your help.

Andrew Poulos
 
B

Bart Van der Donck

Andrew Poulos wrote:
....
I think I found the issue. The files they produce are UTF-16. My
javascript files are UTF-8. When Firefox goes to load my files into a
UTF-16 web page it converts them from UTF-8 to 16 and so it appears that
all the characters go awry.
I'll make sure they use only UTF-8. Thank you for your help.

You're welcome. <script src="X" type="text/javascript"
charset="utf-8"> might help too in your scenario.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top