encodeLenBytes function
Implementation
int encodeLenBytes(int 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 'Length too long (> 4 bytes)';
}
}