Ok, I think I am slowly loosing my sanity... On Wed, 24 Nov 2010 23:48:19 +0100 Jonatan Liljedahl <li...@kymatica.com> wrote:
> In seed you should use f.contents, not f.content. Also, try f.value. > (To see if there are other values in f, print Object.keys(f)) I tried both f.contents and f.value, both are undefined in Seed and Gjs (Gjs seems to print the file plus some stuff when doing print(f)) > > Once I try my "real" log file, Gjs fails with "Error: Failed to > > convert UTF-8 string to JS string: Invalid byte sequence in > > conversion input" > > Perhaps you have non-UTF-8 strings in your log-file? Possibly, as it is from IRC there is potentially everything in there, with everybody using a different encoding. I tried the same file with Python, decoding as UTF-8 fails there as well, so this is the file that's broken. Reading it linewise and figuring out what the encoding of the line is, sounds like the best bet. > One way to read files line by line in seed is this: > > var file = Gio.file_new_for_path(name); > var fstream = file.read(); > var dstream = new Gio.DataInputStream.c_new(fstream); > > var line; > while((line = dstream.read_line())!=undefined) { > print(line); > } > > fstream.close(); > > Don't know if it works in Gjs. That actually works for me as well (and is similar to what I started with, except that I did not know about c_new), but only on Seed. Gjs seems to require some more arguments to read(), read_line() and can't instantiate DataInputStream :/ regards, Marek _______________________________________________ javascript-list mailing list javascript-list@gnome.org http://mail.gnome.org/mailman/listinfo/javascript-list