diff options
Diffstat (limited to 'apps/gui/gwps-common.c')
-rw-r--r-- | apps/gui/gwps-common.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index a6ef9b04d3..7590f493e8 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c | |||
@@ -55,6 +55,19 @@ static void draw_player_fullbar(struct gui_wps *gwps, | |||
55 | /* 3% of 30min file == 54s step size */ | 55 | /* 3% of 30min file == 54s step size */ |
56 | #define MIN_FF_REWIND_STEP 500 | 56 | #define MIN_FF_REWIND_STEP 500 |
57 | 57 | ||
58 | /* Skip leading UTF-8 BOM, if present. */ | ||
59 | static char* skip_utf8_bom(char* buf) | ||
60 | { | ||
61 | unsigned char* s = (unsigned char*) buf; | ||
62 | |||
63 | if(s[0] == 0xef && s[1] == 0xbb && s[2] == 0xbf) | ||
64 | { | ||
65 | buf += 3; | ||
66 | } | ||
67 | |||
68 | return buf; | ||
69 | } | ||
70 | |||
58 | /* | 71 | /* |
59 | * returns the image_id between | 72 | * returns the image_id between |
60 | * a..z and A..Z | 73 | * a..z and A..Z |
@@ -81,7 +94,7 @@ static int get_image_id(int c) | |||
81 | * it returns true if one of these tags is found and handled | 94 | * it returns true if one of these tags is found and handled |
82 | * false otherwise | 95 | * false otherwise |
83 | */ | 96 | */ |
84 | bool wps_data_preload_tags(struct wps_data *data, unsigned char *buf, | 97 | bool wps_data_preload_tags(struct wps_data *data, char *buf, |
85 | const char *bmpdir, size_t bmpdirlen) | 98 | const char *bmpdir, size_t bmpdirlen) |
86 | { | 99 | { |
87 | if(!data || !buf) return false; | 100 | if(!data || !buf) return false; |
@@ -92,14 +105,7 @@ bool wps_data_preload_tags(struct wps_data *data, unsigned char *buf, | |||
92 | (void)bmpdir; | 105 | (void)bmpdir; |
93 | (void)bmpdirlen; | 106 | (void)bmpdirlen; |
94 | #endif | 107 | #endif |
95 | /* jump over the UTF-8 BOM(Byte Order Mark) if exist | 108 | buf = skip_utf8_bom(buf); |
96 | * the BOM for UTF-8 is 3 bytes long and looks like so: | ||
97 | * 1. Byte: 0xEF | ||
98 | * 2. Byte: 0xBB | ||
99 | * 3. Byte: 0xBF | ||
100 | */ | ||
101 | if(buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf) | ||
102 | buf+=3; | ||
103 | 109 | ||
104 | if(*buf == '#') | 110 | if(*buf == '#') |
105 | return true; | 111 | return true; |
@@ -1122,6 +1128,7 @@ void gui_wps_format(struct wps_data *data) | |||
1122 | 1128 | ||
1123 | line = 0; | 1129 | line = 0; |
1124 | subline = 0; | 1130 | subline = 0; |
1131 | buf = skip_utf8_bom(buf); | ||
1125 | data->format_lines[line][subline] = buf; | 1132 | data->format_lines[line][subline] = buf; |
1126 | 1133 | ||
1127 | while ((*buf) && (line < WPS_MAX_LINES)) | 1134 | while ((*buf) && (line < WPS_MAX_LINES)) |