public static void transcodeLoop(ThreadContext context, ByteList fromp, ByteList dest, byte[] sname, byte[] dname, int ecflags, IRubyObject ecopts) { Transcoder ec; ec = econvOpenOpts(context, sname, dname, ecflags, ecopts); if (ec == null) { throw econvOpenExc(context, sname, dname, ecflags); } // TODO: fallback function RubyCoderResult result = ec.transcode(context, fromp, dest); }
public static void transcodeLoop(ThreadContext context, ByteList fromp, ByteList dest, byte[] sname, byte[] dname, int ecflags, IRubyObject ecopts) { Transcoder ec; ec = econvOpenOpts(context, sname, dname, ecflags, ecopts); if (ec == null) { throw econvOpenExc(context, sname, dname, ecflags); } // TODO: fallback function RubyCoderResult result = ec.transcode(context, fromp, dest); }
private void makeReadConversion(ThreadContext context) { if (readconv != null) return; int ecflags; IRubyObject ecopts; byte[] sname, dname; ecflags = this.ecflags & ~EncodingUtils.ECONV_NEWLINE_DECORATOR_WRITE_MASK; ecopts = this.ecopts; if (enc2 != null) { sname = enc2.getName(); dname = enc.getName(); } else { sname = dname = EMPTY_BYTE_ARRAY; } readconv = EncodingUtils.econvOpenOpts(context, sname, dname, ecflags, ecopts); if (readconv == null) { throw EncodingUtils.econvOpenExc(context, sname, dname, ecflags); } // rest of MRI code sets up read/write buffers }
private void makeReadConversion(ThreadContext context) { if (readconv != null) return; int ecflags; IRubyObject ecopts; byte[] sname, dname; ecflags = this.ecflags & ~EncodingUtils.ECONV_NEWLINE_DECORATOR_WRITE_MASK; ecopts = this.ecopts; if (enc2 != null) { sname = enc2.getName(); dname = enc.getName(); } else { sname = dname = EMPTY_BYTE_ARRAY; } readconv = EncodingUtils.econvOpenOpts(context, sname, dname, ecflags, ecopts); if (readconv == null) { throw EncodingUtils.econvOpenExc(context, sname, dname, ecflags); } // rest of MRI code sets up read/write buffers }
public void makeReadConversion(ThreadContext context, int size) { if (readconv == null) { int ecflags; IRubyObject ecopts; byte[] sname, dname; ecflags = encs.ecflags & ~EConvFlags.NEWLINE_DECORATOR_WRITE_MASK; ecopts = encs.ecopts; if (encs.enc2 != null) { sname = encs.enc2.getName(); dname = encs.enc.getName(); } else { sname = dname = EMPTY_BYTE_ARRAY; } readconv = EncodingUtils.econvOpenOpts(context, sname, dname, ecflags, ecopts); if (readconv == null) throw EncodingUtils.econvOpenExc(context, sname, dname, ecflags); cbuf.off = 0; cbuf.len = 0; if (size < IO_CBUF_CAPA_MIN) size = IO_CBUF_CAPA_MIN; cbuf.capa = size; cbuf.ptr = new byte[cbuf.capa]; } }
public void makeReadConversion(ThreadContext context, int size) { if (readconv == null) { int ecflags; IRubyObject ecopts; byte[] sname, dname; ecflags = encs.ecflags & ~EConvFlags.NEWLINE_DECORATOR_WRITE_MASK; ecopts = encs.ecopts; if (encs.enc2 != null) { sname = encs.enc2.getName(); dname = encs.enc.getName(); } else { sname = dname = EMPTY_BYTE_ARRAY; } readconv = EncodingUtils.econvOpenOpts(context, sname, dname, ecflags, ecopts); if (readconv == null) throw EncodingUtils.econvOpenExc(context, sname, dname, ecflags); cbuf.off = 0; cbuf.len = 0; if (size < IO_CBUF_CAPA_MIN) size = IO_CBUF_CAPA_MIN; cbuf.capa = size; cbuf.ptr = new byte[cbuf.capa]; } }
protected void ecopts(ThreadContext context, IRubyObject opts) { if (!opts.isNil()) { EncodingUtils.ioExtractEncodingOption(context, this, opts, null); } if (enc2 != null) { IRubyObject[] outOpts = new IRubyObject[]{opts}; ecflags = EncodingUtils.econvPrepareOpts(context, opts, outOpts); ec = EncodingUtils.econvOpenOpts(context, enc.getName(), enc2.getName(), ecflags, opts); ecopts = opts; } }
protected void ecopts(ThreadContext context, IRubyObject opts) { if (!opts.isNil()) { EncodingUtils.ioExtractEncodingOption(context, this, opts, null); } if (enc2 != null) { IRubyObject[] outOpts = new IRubyObject[]{opts}; ecflags = EncodingUtils.econvPrepareOpts(context, opts, outOpts); ec = EncodingUtils.econvOpenOpts(context, enc.getName(), enc2.getName(), ecflags, opts); ecopts = opts; } }
protected void ecopts(ThreadContext context, IRubyObject opts) { if (!opts.isNil()) { EncodingUtils.ioExtractEncodingOption(context, this, opts, null); } if (enc2 != null) { IRubyObject[] outOpts = new IRubyObject[]{opts}; ecflags = EncodingUtils.econvPrepareOpts(context, opts, outOpts); ec = EncodingUtils.econvOpenOpts(context, enc.getName(), enc2.getName(), ecflags, opts); ecopts = opts; } }
protected void ecopts(ThreadContext context, IRubyObject opts) { if (!opts.isNil()) { EncodingUtils.ioExtractEncodingOption(context, this, opts, null); } if (enc2 != null) { IRubyObject[] outOpts = new IRubyObject[]{opts}; ecflags = EncodingUtils.econvPrepareOpts(context, opts, outOpts); ec = EncodingUtils.econvOpenOpts(context, enc.getName(), enc2.getName(), ecflags, opts); ecopts = opts; } }
ByteList convert_byte(ByteList str, String inputCharset, NKFCharset output) { String outputCharset = output.getCharset(); if (inputCharset == null) { inputCharset = str.getEncoding().toString(); } if (outputCharset.equals(inputCharset)) { return str.dup(); } byte[] outCharsetBytes = outputCharset.getBytes(); EConv ec = EncodingUtils.econvOpenOpts(context, inputCharset.getBytes(), outCharsetBytes, 0, context.nil); if (ec == null) { throw context.runtime.newArgumentError("invalid encoding pair: " + inputCharset + " to " + outputCharset); } ByteList converted = EncodingUtils.econvStrConvert(context, ec, str, EConvFlags.INVALID_REPLACE); converted.setEncoding(context.runtime.getEncodingService().findEncodingOrAliasEntry(outCharsetBytes).getEncoding()); return converted; } }
ByteList convert_byte(ByteList str, String inputCharset, NKFCharset output) { String outputCharset = output.getCharset(); if (inputCharset == null) { inputCharset = str.getEncoding().toString(); } if (outputCharset.equals(inputCharset)) { return str.dup(); } byte[] outCharsetBytes = outputCharset.getBytes(); EConv ec = EncodingUtils.econvOpenOpts(context, inputCharset.getBytes(), outCharsetBytes, 0, context.nil); if (ec == null) { throw context.runtime.newArgumentError("invalid encoding pair: " + inputCharset + " to " + outputCharset); } ByteList converted = EncodingUtils.econvStrConvert(context, ec, str, EConvFlags.INVALID_REPLACE); converted.setEncoding(context.runtime.getEncodingService().findEncodingOrAliasEntry(outCharsetBytes).getEncoding()); return converted; } }
writeconv = EncodingUtils.econvOpenOpts(context, EMPTY_BYTE_ARRAY, EMPTY_BYTE_ARRAY, ecflags, ecopts); if (writeconv == null) { throw EncodingUtils.econvOpenExc(context, EMPTY_BYTE_ARRAY, EMPTY_BYTE_ARRAY, ecflags); writeconv = EncodingUtils.econvOpenOpts(context, senc, denc, ecflags, ecopts); if (writeconv == null) { throw EncodingUtils.econvOpenExc(context, senc, denc, ecflags);
writeconv = EncodingUtils.econvOpenOpts(context, EMPTY_BYTE_ARRAY, EMPTY_BYTE_ARRAY, ecflags, ecopts); if (writeconv == null) { throw EncodingUtils.econvOpenExc(context, EMPTY_BYTE_ARRAY, EMPTY_BYTE_ARRAY, ecflags); writeconv = EncodingUtils.econvOpenOpts(context, senc, denc, ecflags, ecopts); if (writeconv == null) { throw EncodingUtils.econvOpenExc(context, senc, denc, ecflags);
TranscodeFallback fallbackFunc = null; ec = econvOpenOpts(context, sname, dname, ecflags, ecopts);
TranscodeFallback fallbackFunc = null; ec = econvOpenOpts(context, sname, dname, ecflags, ecopts);
Transcoder ec = EncodingUtils.econvOpenOpts(context, fromEncoding.getName(), toEncoding.getName(), ecflags, ecopts); if (ec == null) return value;
Transcoder ec = EncodingUtils.econvOpenOpts(context, fromEncoding.getName(), toEncoding.getName(), ecflags, ecopts); if (ec == null) return value;
} else { EncodingUtils.econvArgs(context, args, encNames, encs, ecflags, ecopts); ec = EncodingUtils.econvOpenOpts(context, encNames[0], encNames[1], ecflags[0], ecopts[0]);
} else { EncodingUtils.econvArgs(context, args, encNames, encs, ecflags, ecopts); ec = EncodingUtils.econvOpenOpts(context, encNames[0], encNames[1], ecflags[0], ecopts[0]);