forked from len0rd/rockbox
Unify opening of utf-8 files (FS#6203). This also adds ignoring the BOM in several places it has been missing (as FS#6071).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18185 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
6485d6d3ba
commit
02103a2fa7
8 changed files with 55 additions and 54 deletions
|
@ -1527,19 +1527,6 @@ static bool load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir)
|
|||
|
||||
#endif /* HAVE_LCD_BITMAP */
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* to setup up the wps-data from a format-buffer (isfile = false)
|
||||
from a (wps-)file (isfile = true)*/
|
||||
bool wps_data_load(struct wps_data *wps_data,
|
||||
|
@ -1604,7 +1591,7 @@ bool wps_data_load(struct wps_data *wps_data,
|
|||
#endif
|
||||
#endif /* __PCTOOL__ */
|
||||
|
||||
int fd = open(buf, O_RDONLY);
|
||||
int fd = open_utf8(buf, O_RDONLY);
|
||||
|
||||
if (fd < 0)
|
||||
return false;
|
||||
|
@ -1639,9 +1626,6 @@ bool wps_data_load(struct wps_data *wps_data,
|
|||
memset(bmp_names, 0, sizeof(bmp_names));
|
||||
#endif
|
||||
|
||||
/* Skip leading UTF-8 BOM, if present. */
|
||||
wps_buffer = skip_utf8_bom(wps_buffer);
|
||||
|
||||
/* parse the WPS source */
|
||||
if (!wps_parse(wps_data, wps_buffer)) {
|
||||
wps_reset(wps_data);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue