stripUTF8BOM checks whether the given buffer begins with a UTF-8 byte order mark (0xEF 0xBB 0xBF) and, if so, returns a truncated slice with the same backing array but with the BOM skipped. If there is no BOM present, the given slice is returned verbatim.
(src []byte)
| 330 | // |
| 331 | // If there is no BOM present, the given slice is returned verbatim. |
| 332 | func stripUTF8BOM(src []byte) []byte { |
| 333 | if bytes.HasPrefix(src, utf8BOM) { |
| 334 | return src[3:] |
| 335 | } |
| 336 | return src |
| 337 | } |