I'm still wet behind the ears hear so bare with me. I'm trying to load a text file into a GtkTextBuffer. When doing so with local text files, no problem. However, when I open a file that I created on my Windows system, the program crashes due to utf8 validation. So used g_utf8_validate() to catch this. However, I need to be able to read this type of file (it's a text file containing assembly code). I'm using something like the following to read the file (using gnome-vfs):

do {
  result = gnome_vfs_read (handle,
          text_buffer,
          BUFFER_SIZE,
          &bytes_read);
  bytes_total += bytes_read;
} while(result == GNOME_VFS_OK);

if(result == GNOME_VFS_ERROR_EOF) {
    if (!g_utf8_validate (text_buffer, (gssize)file_info->size, NULL))
   {
g_debug("editor.c:open_file() Cannot open file. UTF8 validation failed.\n"); /* clean up */
           text_buffer = NULL;
           g_free(text_buffer);
           gnome_vfs_close(handle);
return FALSE; }
bla bla bla....


Is there some easy way to determine the character coding of the file I'm opening and make a conversion before trying to put it into a GtkTextBuffer? Does GnomeVFS have anything? I couldn't find anything in the documentation. I've been trying to figure out how gedit does it by looking through the souce but I'm afraid I'm still quite new to this.

Thanks if you can help or if you took the time to read it but can't help me. :)

Cheers,
- Micah
http://www.micahcarrick.com
_______________________________________________
gnome-devel-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gnome-devel-list

Reply via email to