/** * A version of transcodeLoop for working without any Ruby runtime available. * * MRI: transcode_loop with no fallback and java.lang.String input */ public static ByteList transcodeString(String string, Encoding toEncoding, int ecflags) { Encoding encoding; encoding = getUTF16ForPlatform(); EConv ec = TranscoderDB.open(encoding.getName(), toEncoding.getName(), ecflags); byte[] inBytes = string.getBytes(EncodingUtils.charsetForEncoding(encoding)); Ptr inPos = new Ptr(0); int inStop = inBytes.length; // most encodings will be shorter than UTF-16 for typical input int outStop = (int)((double) inBytes.length / 1.5 + 1); byte[] outBytes = new byte[outStop]; Ptr outPos = new Ptr(0); ByteList destination = new ByteList(outBytes, toEncoding, false); boolean success = transcodeLoop(ec, null, null, null, inBytes, inPos, outBytes, outPos, inStop, outStop, destination, strTranscodingResize); if (!success) { // TODO: anything? } return destination; }
/** * A version of transcodeLoop for working without any Ruby runtime available. * * MRI: transcode_loop with no fallback and java.lang.String input */ public static ByteList transcodeString(String string, Encoding toEncoding, int ecflags) { Encoding encoding; encoding = getUTF16ForPlatform(); EConv ec = TranscoderDB.open(encoding.getName(), toEncoding.getName(), ecflags); byte[] inBytes = string.getBytes(EncodingUtils.charsetForEncoding(encoding)); Ptr inPos = new Ptr(0); int inStop = inBytes.length; // most encodings will be shorter than UTF-16 for typical input int outStop = (int)((double) inBytes.length / 1.5 + 1); byte[] outBytes = new byte[outStop]; Ptr outPos = new Ptr(0); ByteList destination = new ByteList(outBytes, toEncoding, false); boolean success = transcodeLoop(ec, null, null, null, inBytes, inPos, outBytes, outPos, inStop, outStop, destination, strTranscodingResize); if (!success) { // TODO: anything? } return destination; }
boolean success = transcodeLoop(ec, fallbackFunc, context, fallback, inBytes, inPos, outBytes, outPos, inStop, _outStop, destination, resizeFunction);
boolean success = transcodeLoop(ec, fallbackFunc, context, fallback, inBytes, inPos, outBytes, outPos, inStop, _outStop, destination, resizeFunction);
ByteList destp = dest.getByteList(); transcodeLoop(context, fromp, destp, sname_p[0], dname_p[0], ecflags, ecopts);
ByteList destp = dest.getByteList(); transcodeLoop(context, fromp, destp, sname_p[0], dname_p[0], ecflags, ecopts);
Ptr frompPos = new Ptr(fromp.getBegin()); Ptr destpPos = new Ptr(destp.getBegin()); transcodeLoop(context, frompBytes, frompPos, destpBytes, destpPos, frompPos.p + slen, destpPos.p + blen, destp, strTranscodingResize, sname_p[0], dname_p[0], ecflags, ecopts);
Ptr frompPos = new Ptr(fromp.getBegin()); Ptr destpPos = new Ptr(destp.getBegin()); transcodeLoop(context, frompBytes, frompPos, destpBytes, destpPos, frompPos.p + slen, destpPos.p + blen, destp, strTranscodingResize, sname_p[0], dname_p[0], ecflags, ecopts);