From: Niki Roo Date: Thu, 26 May 2022 11:50:47 +0000 (+0200) Subject: nsub: add utf-8 BOM support X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=a1d6d20958687c417e386f2328471db81f394686;p=nsub.git nsub: add utf-8 BOM support --- diff --git a/src/nsub/nsub.c b/src/nsub/nsub.c index 3df4da0..0ea748f 100644 --- a/src/nsub/nsub.c +++ b/src/nsub/nsub.c @@ -128,6 +128,13 @@ song_t *nsub_read(FILE *in, NSUB_FORMAT fmt) { line = new_cstring(); size_t i = 0; while (cstring_readline(line, in)) { + // UTF-8 BOM detection if any + if (!i && cstring_starts_with(line->string, "\xEF\xBB\xBF", 0)) { + cstring_t *tmp = cstring_substring(line->string, 3, 0); + free_cstring(line); + line = tmp; + } + i++; if (!read_a_line(song, line->string)) {