appendTo method

  1. @override
void appendTo(
  1. BitArray bitArray,
  2. List<int> text
)
override

Implementation

@override
void appendTo(BitArray bitArray, List<int> text) {
  for (int i = 0; i < _binaryShiftByteCount; i++) {
    if (i == 0 || (i == 31 && _binaryShiftByteCount <= 62)) {
      // We need a header before the first character, and before
      // character 31 when the total byte code is <= 62
      bitArray.appendBits(31, 5); // BINARY_SHIFT
      if (_binaryShiftByteCount > 62) {
        bitArray.appendBits(_binaryShiftByteCount - 31, 16);
      } else if (i == 0) {
        // 1 <= binaryShiftByteCode <= 62
        bitArray.appendBits(math.min(_binaryShiftByteCount, 31), 5);
      } else {
        // 32 <= binaryShiftCount <= 62 and i == 31
        bitArray.appendBits(_binaryShiftByteCount - 31, 5);
      }
    }
    bitArray.appendBits(text[_binaryShiftStart + i], 8);
  }
}