Invalid byte sequence in conversion input




I am trying to read some text out of a file.  It works if I do it this way:

  while (read_bytes!=0) {
    g_io_channel_read(file_io_channel, readbuffer, READBUFLENGTH, &read_bytes);
    /* Add the text to the text in memory */
    text=g_string_append(text, g_strndup(readbuffer,read_bytes));
  }

however, I tried doing it without the loop by calling
g_io_channel_read_to_end(file_io_channel, &readtext, &length, &error);

This, however, gives an error, specifically that 
"Invalid byte sequence in conversion input"

Given the same file, the first method always works, but the second chokes
on certain files.  Is the second one doing some kind of extra conversion
that the first one isn't?  If so, why?  Can I tell it not to?  I can't
control the contents of the files being read.

Thanks!
-Ron




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