MCPcopy Create free account
hub / github.com/IBM/Project_CodeNet / remove_BOM

Function remove_BOM

tools/tokenizer/libtoken.c:262–277  ·  view source on GitHub ↗

Must be called right after a file is opened as stdin. Will attempt to remove any UTF-8 unicode signature (byte-order mark, BOM) at the beginning of the file. Unicode: U+FEFF UTF-8: EF BB BF First bytes Encoding Must remove? 00 00 FE FF UTF-32 big endian Yes FF FE 00 00 UTF-32 little endian Yes FE FF UTF-16 big endian Yes FF FE UTF-16 li

Source from the content-addressed store, hash-verified

260 otherwise UTF-8 No
261*/
262static void remove_BOM(void)
263{
264 int c1 = getchar();
265 if (c1 == 0xEF) {
266 int c2 = getchar();
267 if (c2 == 0xBB) {
268 int c3 = getchar();
269 if (c3 == 0xBF) {
270 return;
271 }
272 if (c3 != EOF) buffer[buffered++] = c3;
273 }
274 if (c2 != EOF) buffer[buffered++] = c2;
275 }
276 if (c1 != EOF) buffer[buffered++] = c1;
277}
278
279int open_as_stdin(const char *file)
280{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected