Hello,

I have been porting a part of a program to GIO for file monitoring. By
this move I also switched g_file_get/set_contents to the ones
available in the GFile object, g_file_load/replace_contents.

At the first run I was surprised that it didn't work (of course errors
may always be introduced ;-)). Well looks like the code was ok. The
problem is that I read and save files with utf-8 characters and that
is kind of broken here. I reproduced the problem on two machines, one
with glib-2.20.1 and another with glib 2.20.3. I ran a smaller test
case, one in C as my program and another with Python. Turns out the
one in Python doesn't reproduce the problem and I really have no clue
what is going on. The test cases in C and Python are attached.

I hope I'm not the only one reproducing the problem :)

Mike
/* gcc `pkg-config --cflags --libs gio-2.0` test.c -o test */
#include <gio/gio.h>
int main (int argc, char *argv[]) {
    g_type_init ();
    char *text = "Text é";
    GFile *file = g_file_new_for_path ("./test.txt");
    g_file_replace_contents (file, text, -1, NULL, FALSE, 0, NULL, NULL, NULL);
    //g_file_set_contents ("test.txt", text, -1, NULL); // Works fine
    return 0;
}
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to