docs: private void processText() {
  
          int length = content.length();
          int i, j, count, current_set;
  
          if (length > 138) {
              throw new OkapiException("Input data too long");
          }
  
          for (i = 0; i < 144; i++) {
              set[i] = -1;
              character[i] = 0;
          }
  
          for (i = 0; i < length; i++) {
              /* Look up characters in table from Appendix A - this gives
               value and code set for most characters */
              set[i] = MAXICODE_SET[inputData[i]];
              character[i] = MAXICODE_SYMBOL_CHAR[inputData[i]];
          }
  
          // If a character can be represented in more than one code set, pick which version to use.
          if (set[0] == 0) {
              if (character[0] == 13) {
                  character[0] = 0;
              }
              set[0] = 1;
          }
  
          for (i = 1; i < length; i++) {
              if (set[i] == 0) {
                  /* Special character that can be represented in more than one code set. */
                  if (character[i] == 13) {
                      /* Carriage Return */
                      set[i] = bestSurroundingSet(i, length, 1, 5);
                      if (set[i] == 5) {
                          character[i] = 13;
                      } else {
                          character[i] = 0;
                      }
                  } else if (character[i] == 28) {
                      /* FS */
                      set[i] = bestSurroundingSet(i, length, 1, 2, 3, 4, 5);
                      if (set[i] == 5) {
                          character[i] = 32;
                      }
                  } else if (character[i] == 29) {
                      /* GS */
                      set[i] = bestSurroundingSet(i, length, 1, 2, 3, 4, 5);
                      if (set[i] == 5) {
                          character[i] = 33;
                      }
                  } else if (character[i] == 30) {
                      /* RS */
                      set[i] = bestSurroundingSet(i, length, 1, 2, 3, 4, 5);
                      if (set[i] == 5) {
                          character[i] = 34;
                      }
                  } else if (character[i] == 32) {
                      /* Space */
                      set[i] = bestSurroundingSet(i, length, 1, 2, 3, 4, 5);
                      if (set[i] == 1) {
                          character[i] = 32;
                      } else if (set[i] == 2) {
                          character[i] = 47;
                      } else {
                          character[i] = 59;
                      }
                  } else if (character[i] == 44) {
                      /* Comma */
                      set[i] = bestSurroundingSet(i, length, 1, 2);
                      if (set[i] == 2) {
                          character[i] = 48;
                      }
                  } else if (character[i] == 46) {
                      /* Full Stop */
                      set[i] = bestSurroundingSet(i, length, 1, 2);
                      if (set[i] == 2) {
                          character[i] = 49;
                      }
                  } else if (character[i] == 47) {
                      /* Slash */
                      set[i] = bestSurroundingSet(i, length, 1, 2);
                      if (set[i] == 2) {
                          character[i] = 50;
                      }
                  } else if (character[i] == 58) {
                      /* Colon */
                      set[i] = bestSurroundingSet(i, length, 1, 2);
                      if (set[i] == 2) {
                          character[i] = 51;
                      }
                  }
              }
          }
  
          for (i = length; i < set.length; i++) {
              /* Add the padding */
              if (set[length - 1] == 2) {
                  set[i] = 2;
              } else {
                  set[i] = 1;
              }
              character[i] = 33;
          }
  
          /* Find candidates for number compression (not allowed in primary message in modes 2 and 3). */
          if (mode == 2 || mode == 3) {
              j = 9;
          } else {
              j = 0;
          }
          count = 0;
          for (i = j; i < 143; i++) {
              if (set[i] == 1 && character[i] >= 48 && character[i] <= 57) {
                  /* Character is a number */
                  count++;
              } else {
                  count = 0;
              }
              if (count == 9) {
                  /* Nine digits in a row can be compressed */
                  set[i] = 6;
                  set[i - 1] = 6;
                  set[i - 2] = 6;
                  set[i - 3] = 6;
                  set[i - 4] = 6;
                  set[i - 5] = 6;
                  set[i - 6] = 6;
                  set[i - 7] = 6;
                  set[i - 8] = 6;
                  count = 0;
              }
          }
  
          /* Add shift and latch characters */
          current_set = 1;
          i = 0;
          do {
              if ((set[i] != current_set) && (set[i] != 6)) {
                  switch (set[i]) {
                      case 1:
                          if (i + 1 < set.length && set[i + 1] == 1) {
                              if (i + 2 < set.length && set[i + 2] == 1) {
                                  if (i + 3 < set.length && set[i + 3] == 1) {
                                      /* Latch A */
                                      insert(i, 63);
                                      current_set = 1;
                                      length++;
                                      i += 3;
                                  } else {
                                      /* 3 Shift A */
                                      insert(i, 57);
                                      length++;
                                      i += 2;
                                  }
                              } else {
                                  /* 2 Shift A */
                                  insert(i, 56);
                                  length++;
                                  i++;
                              }
                          } else {
                              /* Shift A */
                              insert(i, 59);
                              length++;
                          }
                          break;
                      case 2:
                          if (i + 1 < set.length && set[i + 1] == 2) {
                              /* Latch B */
                              insert(i, 63);
                              current_set = 2;
                              length++;
                              i++;
                          } else {
                              /* Shift B */
                              insert(i, 59);
                              length++;
                          }
                          break;
                      case 3:
                          if (i + 3 < set.length && set[i + 1] == 3 && set[i + 2] == 3 && set[i + 3] == 3) {
                              /* Lock In C */
                              insert(i, 60);
                              insert(i, 60);
                              current_set = 3;
                              length++;
                              i += 3;
                          } else {
                              /* Shift C */
                              insert(i, 60);
                              length++;
                          }
                          break;
                      case 4:
                          if (i + 3 < set.length && set[i + 1] == 4 && set[i + 2] == 4 && set[i + 3] == 4) {
                              /* Lock In D */
                              insert(i, 61);
                              insert(i, 61);
                              current_set = 4;
                              length++;
                              i += 3;
                          } else {
                              /* Shift D */
                              insert(i, 61);
                              length++;
                          }
                          break;
                      case 5:
                          if (i + 3 < set.length && set[i + 1] == 5 && set[i + 2] == 5 && set[i + 3] == 5) {
                              /* Lock In E */
                              insert(i, 62);
                              insert(i, 62);
                              current_set = 5;
                              length++;
                              i += 3;
                          } else {
                              /* Shift E */
                              insert(i, 62);
                              length++;
                          }
                          break;
                      default:
                          throw new OkapiException("Unexpected set " + set[i] + " at index " + i + ".");
                  }
                  i++;
              }
              i++;
          } while (i < set.length);
  
          /* Number compression has not been forgotten! It's handled below. */
          i = 0;
          do {
              if (set[i] == 6) {
                  /* Number compression */
                  int value = 0;
                  for (j = 0; j < 9; j++) {
                      value *= 10;
                      value += (character[i + j] - '0');
                  }
                  character[i] = 31; /* NS */
                  character[i + 1] = (value & 0x3f000000) >> 24;
                  character[i + 2] = (value & 0xfc0000) >> 18;
                  character[i + 3] = (value & 0x3f000) >> 12;
                  character[i + 4] = (value & 0xfc0) >> 6;
                  character[i + 5] = (value & 0x3f);
                  i += 6;
                  for (j = i; j < 140; j++) {
                      set[j] = set[j + 3];
                      character[j] = character[j + 3];
                  }
                  length -= 3;
              } else {
                  i++;
              }
          } while (i < set.length);
  
          /* Inject ECI codes to beginning of data, according to Table 3 */
          if (eciMode != 3) {
              insert(0, 27); // ECI
  
              if ((eciMode >= 0) && (eciMode <= 31)) {
                  insert(1, eciMode & 0x1F);
                  length += 2;
              }
  
              if ((eciMode >= 32) && (eciMode <= 1023)) {
                  insert(1, 0x20 + (eciMode >> 6));
                  insert(2, eciMode & 0x3F);
                  length += 3;
              }
  
              if ((eciMode >= 1024) && (eciMode <= 32767)) {
                  insert(1, 0x30 + (eciMode >> 12));
                  insert(2, (eciMode >> 6) & 0x3F);
                  insert(3, eciMode & 0x3F);
                  length += 4;
              }
  
              if ((eciMode >= 32768) && (eciMode <= 999999)) {
                  insert(1, 0x38 + (eciMode >> 18));
                  insert(2, (eciMode >> 12) & 0x3F);
                  insert(3, (eciMode >> 6) & 0x3F);
                  insert(4, eciMode & 0x3F);
                  length += 5;
              }
          }
  
          /* Make sure we haven't exceeded the maximum data length. */
          int maxLength;
          if (mode == 2 || mode == 3) {
              maxLength = 84;
          } else if (mode == 4 || mode == 6) {
              maxLength = 93;
          } else if (mode == 5) {
              maxLength = 77;
          } else {
              maxLength = 0; // impossible
          }
          if (length > maxLength) {
              throw new OkapiException("Input data too long");
          }
      }