code: public EConvResult convert(byte[] in, Ptr inPtr, int inStop, byte[] out, Ptr outPtr, int outStop, int flags) {
          started = true;
  
          if (in == null || inPtr == null) {
              in = NULL_STRING;
              inPtr = Ptr.NULL;
              inStop = 0;
          }
  
          if (out == null || outPtr == null) {
              out = NULL_STRING;
              outPtr = Ptr.NULL;
              outStop = 0;
          }
  
          resume: while (true) {
              EConvResult ret = convertInternal(in, inPtr, inStop, out, outPtr, outStop, flags);
              if (ret.isInvalidByteSequence() || ret.isIncompleteInput()) {
                  switch (this.flags & INVALID_MASK) {
                  case INVALID_REPLACE:
                      if (outputReplacementCharacter() == 0) continue resume;
                  }
              }
  
              if (ret.isUndefinedConversion()) {
                  switch (this.flags & UNDEF_MASK) {
                  case UNDEF_REPLACE:
                      if (outputReplacementCharacter() == 0) continue resume;
                      break;
                  case UNDEF_HEX_CHARREF:
                      if (outputHexCharref() == 0) continue resume;
                      break;
                  }
              }
              return ret;
          }
      }
docs: /* rb_econv_convert