Re: Writing a buffer with UTF-8 content.
- From: Clemens <clemens lab21 org>
- To: Yaa101 <yaa101 xs4all nl>
- Cc: "gnome-shell-list gnome org" <gnome-shell-list gnome org>
- Subject: Re: Writing a buffer with UTF-8 content.
- Date: Thu, 26 Jul 2012 19:15:30 +0200
Am 26.07.2012 18:08, schrieb Yaa101:
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?
hi,
have you tried to convert the string before writing?
http://developer.gnome.org/glib/stable/glib-Character-Set-Conversion.html
i was writing to a file in an extension, there i used
const Me = imports.misc.extensionUtils.getCurrentExtension(); let
file = Me.dir.get_child("filename.json");
file.replace_contents(JSON.stringify(this._settings, null, 2), null,
false, 0, null);
maybe this work (obviously only if you file is in your extension dir)
cheers
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]