docs: private static int getBinaryLength(int version, QrMode[] inputModeUnoptimized, int[] inputData, boolean gs1, int eciMode) {
  
          int i, j;
          QrMode currentMode;
          int inputLength = inputModeUnoptimized.length;
          int count = 0;
          int alphaLength;
          int percent = 0;
  
          // ZINT NOTE: in Zint, this call modifies the input mode array directly; here, we leave
          // the original array alone so that subsequent binary length checks don't irrevocably
          // optimize the mode array for the wrong QR Code version
          QrMode[] inputMode = applyOptimisation(version, inputModeUnoptimized);
  
          currentMode = QrMode.NULL;
  
          if (gs1) {
              count += 4;
          }
  
          if (eciMode != 3) {
              count += 12;
          }
  
          for (i = 0; i < inputLength; i++) {
              if (inputMode[i] != currentMode) {
                  count += 4;
                  switch (inputMode[i]) {
                      case KANJI:
                          count += tribus(version, 8, 10, 12);
                          count += (blockLength(i, inputMode) * 13);
                          break;
                      case BINARY:
                          count += tribus(version, 8, 16, 16);
                          for (j = i; j < (i + blockLength(i, inputMode)); j++) {
                              if (inputData[j] > 0xff) {
                                  count += 16;
                              } else {
                                  count += 8;
                              }
                          }
                          break;
                      case ALPHANUM:
                          count += tribus(version, 9, 11, 13);
                          alphaLength = blockLength(i, inputMode);
                          // In alphanumeric mode % becomes %%
                          if (gs1) {
                              for (j = i; j < (i + alphaLength); j++) { // TODO: need to do this only if in GS1 mode? or is the other code wrong? https://sourceforge.net/p/zint/tickets/104/#227b
                                  if (inputData[j] == '%') {
                                      percent++;
                                  }
                              }
                          }
                          alphaLength += percent;
                          switch (alphaLength % 2) {
                              case 0:
                                  count += (alphaLength / 2) * 11;
                                  break;
                              case 1:
                                  count += ((alphaLength - 1) / 2) * 11;
                                  count += 6;
                                  break;
                          }
                          break;
                      case NUMERIC:
                          count += tribus(version, 10, 12, 14);
                          switch (blockLength(i, inputMode) % 3) {
                              case 0:
                                  count += (blockLength(i, inputMode) / 3) * 10;
                                  break;
                              case 1:
                                  count += ((blockLength(i, inputMode) - 1) / 3) * 10;
                                  count += 4;
                                  break;
                              case 2:
                                  count += ((blockLength(i, inputMode) - 2) / 3) * 10;
                                  count += 7;
                                  break;
                          }
                          break;
                  }
                  currentMode = inputMode[i];
              }
          }
  
          return count;
      }