stripBom function
Strips a UTF-8 BOM if present and returns both the BOM and the trailing text.
Implementation
BomStripResult stripBom(String content) {
return content.startsWith('\uFEFF')
? (bom: '\uFEFF', text: content.substring(1))
: (bom: '', text: content);
}