Hi gang! I recently scored gold in managing-to, with much help, get a Javascript local file reader working in my newest Mozilla... via approved xpcom methods. A directory of results and test files, can be found at...

http://www.winternet.com/~wingnut/html/test/localfile_readers/

You'll need to move those files to your local drives if you want to try those. Marias files are just some test text files... one in ascii, one in unicode.

Problem: A short JS code-spam from ns_read12a/u shows...

inputStream.init(file, 0x01, 0, 0);

     var sInputStream = Components.classes
["@mozilla.org/scriptableinputstream;1"].createInstance
(Components.interfaces.nsIScriptableInputStream);

sInputStream.init(inputStream);

return sInputStream.read(sInputStream.available());

The return is sent to a buffer where its .split("\n"), and then doc.written from resulting array. But... the above code does not read a unicode text file. Does anyone have any ideas about unicode reading? A search in THIS group for 'unicode' sure brought up a pile of interesting reading, but mostly about unicode xpcom strings.

sInputStream.available() is a good number, so the actual problem seems to be with the .read(). (The unicode file read seems to return 3 bytes of the 49614 available in Marias_u.tdb unicode testfile. Marias_a.tdb ASCII-ish testfile works fine.)

I'm WAY over my head with this comment, but... is this a job for nsUnicharInputStream or maybe UTF8ConverterStream? My searches for UTF8ConverterStream found little. Anyone know of some syntax help or docs for those? Am I going to get a tumor if I continue pursuit of this? :)

PS: Thanks to Erik van der Poel for his excellent posting in "Encoding Wars --- more in the Big String Story" in this group! Much good unicode info there... well presented.

Thanks heaps & best wishes to all!
Wingnut
Minneapolis




Reply via email to