Writing a buffer with UTF-8 content.



Hi all,

I am having trouble writing a buffer with UTF-8 content to a file.

I know that GLib.file_set_contents will not do the job because it
writes ISO-8859-1 instead of UTF-8.

I tried to get it done with this code:

let gFile = Gio.file_new_for_path(this._path);
let gFileOutputStream =
gFile.replace(null, false, Gio.FileCreateFlags.NONE, null);
gFileOutputStream.write(data, datalen, null);
gFileOutputStream.close(null);

GJS throws me a "Unhandled GType GCancellable unpacking GArgument from
Number" and stops.

I cannot find any reference to "Unhandled GType GCancellable unpacking
GArgument from Number" in google.

Can somebody tell me what I am doing wrong, or tell me how to
successfull write a buffer with UTF-8 content to a file?


-- 
(o_
//\  Regards, Groeten,
V_/_ Bas Burger.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]