encodeLenBytes static method

int encodeLenBytes(
  1. dynamic len
)

Implementation

static int encodeLenBytes(len) {
  if (len <= 0x7f) {
    return 1;
  } else if (len <= 0xff) {
    return 2;
  } else if (len <= 0xffff) {
    return 3;
  } else if (len <= 0xffffff) {
    return 4;
  } else {
    throw Exception("Length too long (> 4 bytes)");
  }
}