code: public int makeReplacement() {
          if (replacementString != null) return 0;
  
          byte[] insEnc = encodingToInsertOutput();
  
          final byte[] replEnc;
          final int len;
          final byte[] replacement;
  
          if (insEnc.length != 0) {
              // Transcoding transcoding = lastTranscoding;
              // Transcoder transcoder = transcoding.transcoder;
              // Encoding enc = EncodingDB.getEncodings().get(transcoder.destination).getEncoding();
  
              // get_replacement_character
              if (caseInsensitiveEquals(insEnc, "UTF-8".getBytes())) {
                  len = 3;
                  replEnc = "UTF-8".getBytes();
                  replacement = new byte[] { (byte) 0xEF, (byte) 0xBF, (byte) 0xBD };
              } else {
                  len = 1;
                  replEnc = "US-ASCII".getBytes();
                  replacement = new byte[] { '?' };
              }
          } else {
              len = 1;
              replEnc = NULL_STRING;
              replacement = new byte[] { '?' };
          }
  
          replacementString = replacement;
          replacementLength = len;
          replacementEncoding = replEnc;
          return 0;
      }
docs: /* make_replacement