Index: apps/misc.c
===================================================================
RCS file: /cvsroot/rockbox/apps/misc.c,v
retrieving revision 1.66
diff -u -r1.66 misc.c
--- apps/misc.c	29 Sep 2006 06:22:43 -0000	1.66
+++ apps/misc.c	17 Oct 2006 20:45:53 -0000
@@ -694,3 +694,23 @@
 
     return 0;
 }
+
+
+/** @brief open a utf-8 file, set file descriptor to first byte.
+ *         Skip BOM if present. Identical to open() otherwise
+ */
+int open_utf8(const char* pathname, int flags)
+{
+    int fd;
+    unsigned char bom[3];
+
+    fd = open(pathname, flags);
+    if(fd < 0) return fd;
+
+    read(fd, bom, 3);
+    /* check for BOM */
+    if(!(bom[0] == 0xef && bom[1] == 0xbb && bom[2] == 0xbf))
+	lseek(fd, 0, SEEK_SET);
+    return fd;
+}
+
Index: apps/misc.h
===================================================================
RCS file: /cvsroot/rockbox/apps/misc.h,v
retrieving revision 1.16
diff -u -r1.16 misc.h
--- apps/misc.h	4 Dec 2005 15:23:46 -0000	1.16
+++ apps/misc.h	17 Oct 2006 20:45:53 -0000
@@ -55,4 +55,5 @@
 void car_adapter_mode_init(void);
 extern int show_logo(void);
 
+int open_utf8(const char* pathname, int flags);
 #endif
Index: apps/playlist.c
===================================================================
RCS file: /cvsroot/rockbox/apps/playlist.c,v
retrieving revision 1.174
diff -u -r1.174 playlist.c
--- apps/playlist.c	9 Oct 2006 10:54:16 -0000	1.174
+++ apps/playlist.c	17 Oct 2006 20:45:53 -0000
@@ -504,15 +504,6 @@
             break;
         
         p = (unsigned char *)buffer;
-
-        /* utf8 BOM at beginning of file? */
-        if(i == 0 && nread > 3 
-           && *p == 0xef && *(p+1) == 0xbb && *(p+2) == 0xbf) {
-            nread -= 3;
-            p += 3;
-            i += 3;
-        }
-
         for(count=0; count < nread; count++,p++) {
 
             /* Are we on a new line? */
@@ -1258,7 +1249,7 @@
         else
         {
             if(-1 == playlist->fd)
-                playlist->fd = open(playlist->filename, O_RDONLY);
+                playlist->fd = open_utf8(playlist->filename, O_RDONLY);
             
             fd = playlist->fd;
         }
Index: apps/settings.c
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.c,v
retrieving revision 1.428
diff -u -r1.428 settings.c
--- apps/settings.c	11 Oct 2006 09:12:23 -0000	1.428
+++ apps/settings.c	17 Oct 2006 20:45:54 -0000
@@ -1536,7 +1536,7 @@
     int fd;
     char line[128];
 
-    fd = open(file, O_RDONLY);
+    fd = open_utf8(file, O_RDONLY);
     if (fd < 0)
         return false;
 
Index: apps/gui/gwps-common.c
===================================================================
RCS file: /cvsroot/rockbox/apps/gui/gwps-common.c,v
retrieving revision 1.63
diff -u -r1.63 gwps-common.c
--- apps/gui/gwps-common.c	29 Aug 2006 12:54:22 -0000	1.63
+++ apps/gui/gwps-common.c	17 Oct 2006 20:45:54 -0000
@@ -64,19 +64,6 @@
                                 /* 3% of 30min file == 54s step size */
 #define MIN_FF_REWIND_STEP 500
 
-/* Skip leading UTF-8 BOM, if present. */
-static char* skip_utf8_bom(char* buf)
-{
-    unsigned char* s = (unsigned char*) buf;
-    
-    if(s[0] == 0xef && s[1] == 0xbb && s[2] == 0xbf)
-    {
-        buf += 3;
-    }
-    
-    return buf;
-}
-
 /*
  * returns the image_id between
  * a..z and A..Z
@@ -117,7 +104,6 @@
     (void)bmpdir;
     (void)bmpdirlen;
 #endif
-    buf = skip_utf8_bom(buf);
     
     if(*buf == '#')
         return true;
@@ -1513,7 +1499,6 @@
     
     line = 0;
     subline = 0;
-    buf = skip_utf8_bom(buf);
     data->format_lines[line][subline] = buf;
 
     while ((*buf) && (line < WPS_MAX_LINES))
Index: apps/gui/gwps.c
===================================================================
RCS file: /cvsroot/rockbox/apps/gui/gwps.c,v
retrieving revision 1.52
diff -u -r1.52 gwps.c
--- apps/gui/gwps.c	22 Aug 2006 08:23:24 -0000	1.52
+++ apps/gui/gwps.c	17 Oct 2006 20:45:54 -0000
@@ -737,7 +737,7 @@
         char *bmpdir = strrchr(buf, '.');
         bmpdirlen = bmpdir - buf;
 
-        fd = open(buf, O_RDONLY);
+        fd = open_utf8(buf, O_RDONLY);
 
         if (fd >= 0)
         {
Index: apps/recorder/radio.c
===================================================================
RCS file: /cvsroot/rockbox/apps/recorder/radio.c,v
retrieving revision 1.113
diff -u -r1.113 radio.c
--- apps/recorder/radio.c	12 Oct 2006 19:27:00 -0000	1.113
+++ apps/recorder/radio.c	17 Oct 2006 20:45:55 -0000
@@ -1021,7 +1021,7 @@
         snprintf(filepreset, sizeof(filepreset), "%s/%s.fmr",
             FMPRESET_PATH, filename);
     
-    fd = open(filepreset, O_RDONLY);
+    fd = open_utf8(filepreset, O_RDONLY);
     if(fd >= 0)
     {
         while(!done && num_presets < MAX_PRESETS)
