stripBom function

BomStripResult stripBom(
  1. String content
)

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);
}