rightEncode static method

Uint8List rightEncode(
  1. int strLen
)

Implementation

static Uint8List rightEncode(int strLen) {
  var n = 1;
  var v = strLen;
  while ((v >>= 8) != 0) {
    n++;
  }

  var b = Uint8List(n + 1);

  b[n] = n;

  for (var i = 0; i < n; i++) {
    b[i] = strLen >> (8 * (n - i - 1));
  }

  return b;
}