docs: private static void decodeTextSegment(BitSource bits, StringBuilder result) throws FormatException {
      // Three Text values are encoded in a 16-bit value as
      // (1600 * C1) + (40 * C2) + C3 + 1
      // TODO(bbrown): The Upper Shift with Text doesn't work in the 4 value scenario all the time
      boolean upperShift = false;
  
      int[] cValues = new int[3];
      int shift = 0;
      do {
        // If there is only one byte left then it will be encoded as ASCII
        if (bits.available() == 8) {
          return;
        }
        int firstByte = bits.readBits(8);
        if (firstByte == 254) {  // Unlatch codeword
          return;
        }
  
        parseTwoBytes(firstByte, bits.readBits(8), cValues);
  
        for (int i = 0; i < 3; i++) {
          int cValue = cValues[i];
          switch (shift) {
            case 0:
              if (cValue < 3) {
                shift = cValue + 1;
              } else if (cValue < TEXT_BASIC_SET_CHARS.length) {
                char textChar = TEXT_BASIC_SET_CHARS[cValue];
                if (upperShift) {
                  result.append((char) (textChar + 128));
                  upperShift = false;
                } else {
                  result.append(textChar);
                }
              } else {
                throw FormatException.getFormatInstance();
              }
              break;
            case 1:
              if (upperShift) {
                result.append((char) (cValue + 128));
                upperShift = false;
              } else {
                result.append((char) cValue);
              }
              shift = 0;
              break;
            case 2:
              // Shift 2 for Text is the same encoding as C40
              if (cValue < TEXT_SHIFT2_SET_CHARS.length) {
                char textChar = TEXT_SHIFT2_SET_CHARS[cValue];
                if (upperShift) {
                  result.append((char) (textChar + 128));
                  upperShift = false;
                } else {
                  result.append(textChar);
                }
              } else {
                switch (cValue) {
                  case 27: // FNC1
                    result.append((char) 29); // translate as ASCII 29
                    break;
                  case 30: // Upper Shift
                    upperShift = true;
                    break;
                  default:
                    throw FormatException.getFormatInstance();
                }
              }
              shift = 0;
              break;
            case 3:
              if (cValue < TEXT_SHIFT3_SET_CHARS.length) {
                char textChar = TEXT_SHIFT3_SET_CHARS[cValue];
                if (upperShift) {
                  result.append((char) (textChar + 128));
                  upperShift = false;
                } else {
                  result.append(textChar);
                }
                shift = 0;
              } else {
                throw FormatException.getFormatInstance();
              }
              break;
            default:
              throw FormatException.getFormatInstance();
          }
        }
      } while (bits.available() > 0);
    }