hasUtf32leBom function

bool hasUtf32leBom(
  1. List<int> utf32EncodedBytes, [
  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 hasUtf32leBom(List<int> utf32EncodedBytes, [int offset = 0, int? length]) {
  var end = length != null ? offset + length : utf32EncodedBytes.length;
  return (offset + 4) <= end &&
      utf32EncodedBytes[offset] == UNICODE_UTF_BOM_LO &&
      utf32EncodedBytes[offset + 1] == UNICODE_UTF_BOM_HI &&
      utf32EncodedBytes[offset + 2] == 0 &&
      utf32EncodedBytes[offset + 3] == 0;
}