Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > UTF-16 + firefox +javascript = null

Reply
Thread Tools

UTF-16 + firefox +javascript = null

 
 
Andrew Poulos
Guest
Posts: n/a
 
      04-20-2009
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
 
Reply With Quote
 
 
 
 
Bart Van der Donck
Guest
Posts: n/a
 
      04-20-2009
Andrew Poulos wrote:

> 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-.
- 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,

--
Bart
 
Reply With Quote
 
 
 
 
Andrew Poulos
Guest
Posts: n/a
 
      04-20-2009
Bart Van der Donck wrote:
> Andrew Poulos wrote:
>
>> 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-.
> - 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
 
Reply With Quote
 
Bart Van der Donck
Guest
Posts: n/a
 
      04-20-2009
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.

--
Bart
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
createImage sometime returns null and sometime returns non-null. vizlab Java 3 10-17-2007 11:21 AM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM
difference between null object and null string gokul.b@gmail.com Java 16 10-12-2005 06:43 PM
VB.NET Null to SQL Null (ASP.NET 2.0 GridView) Kivak Wolf ASP .Net 2 06-28-2005 02:01 PM
Is there a null ostream (like /dev/null) in cpp? Bo Peng C++ 13 07-18-2004 07:17 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57