codeLengthAt method

int codeLengthAt(
  1. Uint8List bytes,
  2. int offset
)

Implementation

int codeLengthAt(Uint8List bytes, int offset) {
  if (isIdentity) return identityBytes;
  for (int length = 1; length <= 4 && offset + length <= bytes.length; length++) {
    int code = 0;
    for (int i = 0; i < length; i++) {
      code = (code << 8) | bytes[offset + i];
    }
    for (final UPdfCodespace space in codespaces) {
      if (space.byteLength == length && space.contains(code)) return length;
    }
  }
  return codespaces.isEmpty ? 1 : codespaces.first.byteLength;
}