getLengthBits method

int getLengthBits(
  1. int type
)

Implementation

int getLengthBits(int type) {
  if (type < 1 || type > 40) throw RangeError.range(type, 1, 40, "type");

  if (type < 10) {
    return switch (this) {
      numeric => 10,
      alphaNumeric => 9,
      byte => 8,
      kanji => 8,
      eci => 0,
    };
  } else if (type < 27) {
    return switch (this) {
      numeric => 12,
      alphaNumeric => 11,
      byte => 16,
      kanji => 10,
      eci => 0,
    };
  } else {
    return switch (this) {
      numeric => 14,
      alphaNumeric => 13,
      byte => 16,
      kanji => 12,
      eci => 0,
    };
  }
}