| 1 | module util |
| 2 | |
| 3 | pub fn skip_bom(file_content string) string { |
| 4 | mut raw_text := file_content |
| 5 | // BOM check |
| 6 | if raw_text.len >= 3 { |
| 7 | unsafe { |
| 8 | c_text := raw_text.str |
| 9 | if c_text[0] == 0xEF && c_text[1] == 0xBB && c_text[2] == 0xBF { |
| 10 | // skip three BOM bytes |
| 11 | offset_from_begin := 3 |
| 12 | raw_text = tos(c_text[offset_from_begin], vstrlen(c_text) - offset_from_begin) |
| 13 | } |
| 14 | } |
| 15 | } |
| 16 | return raw_text |
| 17 | } |
| 18 |