GNOME Bugzilla – Bug 658312
GLib file_set_contents(string) doesn't encode string as utf
Last modified: 2011-09-07 01:39:00 UTC
Environment: I am using gjs/gobject-introspection to call into GLib.file_set_contents. Repro: Call GLib.file_set_contents with gchar* contents="séance" Expected behavior: The saved file should contain following hex: 0000000: 73c3 a961 6e63 650a Actual behavior: Instead it contains following: 0000000: 73e9 616e 6365 0a -- For "é", the character getting saved is _e9_ (which I suppose is ISO-8859 encoding); it should be saved as _c3a9_. Some screenshots of this: - http://ompldr.org/vYTU1dg/utf8_gjs.jpg - http://ompldr.org/vYTU2cg/utf8_filediff.jpg
g_file_set_contents has no chance to do what you ask here, since it does not know what encoding the given string might be in. It is your responsibility to pass the contents in a suitable form.