hasUtf16leBom function

bool hasUtf16leBom(
  1. List<int> utf16EncodedBytes, [
  2. int offset = 0,
  3. int? length
])

Identifies whether a List of bytes starts (based on offset) with a little-endian byte-order marker (BOM).

Implementation

bool hasUtf16leBom(List<int> utf16EncodedBytes, [int offset = 0, int? length]) {
  var end = length != null ? offset + length : utf16EncodedBytes.length;
  return (offset + 2) <= end &&
      utf16EncodedBytes[offset] == UNICODE_UTF_BOM_LO &&
      utf16EncodedBytes[offset + 1] == UNICODE_UTF_BOM_HI;
}