code: public int setReplacement(byte[] str, int p, int len, byte[] encname) {
          byte[] encname2 = encodingToInsertOutput();
  
          final byte[] str2;
          final int p2 = 0;
          final int len2;
  
          if (encname2.length == 0 || caseInsensitiveEquals(encname, encname2)) {
              str2 = new byte[len];
              System.arraycopy(str, p, str2, 0, len); // ??
              len2 = len;
              encname2 = encname;
          } else {
              Ptr len2p = new Ptr();
              str2 = allocateConvertedString(encname, encname2, str, p, len, null, len2p);
              if (str2 == null) return -1;
              len2 = len2p.p;
          }
  
          replacementString = str2;
          replacementLength = len2;
          replacementEncoding = encname2;
          return 0;
      }
docs: /* rb_econv_set_replacement