unitsToBase2 function

List unitsToBase2(
  1. List units,
  2. String encoding,
  3. bool format
)

binary

Implementation

List unitsToBase2(List units, String encoding, bool format) {
  List ret = [];

  for (int i = 0; i < units.length; i++) {
    int unit = units[i];
    var binaryUnit;

    if (format) {
      if (encoding == "utf8") {
        binaryUnit = unit.toRadixString(2);
        while (binaryUnit.length < 8) {
          binaryUnit = '0' + binaryUnit;
        }
      }
    } else {
      if (encoding == "utf8") {
        binaryUnit = unit.toRadixString(2);
      }
    }
    ret.add(binaryUnit);
  }
  return ret;
}