readHexString static method

UPdfString readHexString(
  1. UDocCursor cursor
)

Implementation

static UPdfString readHexString(UDocCursor cursor) {
  cursor.skip(1);
  final List<int> out = <int>[];
  int high = -1;
  while (!cursor.isEmpty) {
    final int byte = cursor.u8();
    if (byte == 0x3E) break;
    final int digit = _hex(byte);
    if (digit < 0) continue;
    if (high < 0) {
      high = digit;
    } else {
      out.add((high << 4) | digit);
      high = -1;
    }
    if (out.length > uDocMaxStringLength) break;
  }
  if (high >= 0) out.add(high << 4);
  return UPdfString(Uint8List.fromList(out), hex: true);
}