** Skip an optional BOM at the start of a stream. If there is an ** incomplete BOM (the first character is correct but the rest is ** not), returns the first character anyway to force an error ** (as no chunk can start with 0xEF). */
| 753 | ** (as no chunk can start with 0xEF). |
| 754 | */ |
| 755 | static int skipBOM (FILE *f) { |
| 756 | int c = getc(f); /* read first character */ |
| 757 | if (c == 0xEF && getc(f) == 0xBB && getc(f) == 0xBF) /* correct BOM? */ |
| 758 | return getc(f); /* ignore BOM and return next char */ |
| 759 | else /* no (valid) BOM */ |
| 760 | return c; /* return first character */ |
| 761 | } |
| 762 | |
| 763 | |
| 764 | /* |