[Project_owners] Reading and writing arbitrary unicode strings to file

Carl carlpny at yahoo.com
Fri Aug 19 12:31:40 EDT 2005


Hi everyone,

I'm afraid my knowledge of unicode is lax.

My extension loads arbitrary websites using
XMLHttpRequest's responseText.  It then saves the
source to a file and opens it later.  The problem is
that the stream.write() function doesn't correctly
save unicode characters.

This website doesn't seem to give me a convenient
solution:
http://developer.mozilla.org/en/docs/Writing_textual_data#Converting_a_string_into_a_stream

It seems to say that there is no way whatsoever to
read UTF-16 and UTF-32 files in the current release of
Firefox.

Can't an arbitrary website be encoded using any of
UTF-8, UTF-16, or UTF-32?  If so, how can I figure out
what the encoding is?  I could just go through the
entire string and replace all unicode character with
\u#### but this needs to be an efficient function
since it is called all the time in my extension.

Any recommended ways to save and load arbitrary
unicode strings?

Thanks,
Carl

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Project_owners mailing list