diff -r faab25d520dd -r 08b03c341e61 bl/textfileutils.c --- a/bl/textfileutils.c Fri Jan 27 16:18:02 2012 +0000 +++ b/bl/textfileutils.c Sun Feb 19 09:56:28 2012 +0000 @@ -6,25 +6,28 @@ * Read a file into memory (which should be freed with mem_free when no * longer required). Returns NULL on error and outputs a suitable error * message to stderr. - * DOS-style line endings are handled transparently even on platforms which - * don't normally use this format. + * DOS-style line endings and UTF-8 BOM are handled transparently even + * on platforms which don't normally use these formats. */ gboolean file_get_contents_text(const char *filename,char **contents, size_t *length) { int i; - char *raw; + unsigned char *raw; size_t raw_length; GString *string; GError *error=NULL; - if (!g_file_get_contents(filename,&raw,&raw_length,&error)) + if (!g_file_get_contents(filename,(char *)&raw,&raw_length,&error)) { fprintf(stderr,"%s: %s\n",filename,error->message); g_error_free(error); return FALSE; } string=g_string_new(NULL); - for(i=0;i=3 && raw[0]==0xEF && raw[1]==0xBB && raw[2]==0xBF) + i+=3; /* Skip BOM (U+FEFF) */ + for(;i