Examples of KCode


Examples of org.jruby.util.KCode

     */
    @JRubyMethod(name = {"quote", "escape"}, required = 1, optional = 1, meta = true)
    public static RubyString quote(IRubyObject recv, IRubyObject[] args) {
        IRubyObject kcode = args.length == 2 ? args[1] : null;
        IRubyObject str = args[0];
        KCode code = recv.getRuntime().getKCode();

        if (kcode != null && !kcode.isNil()) {
            code = KCode.create(recv.getRuntime(), kcode.toString());
        }
       
View Full Code Here

Examples of org.jruby.util.KCode

            } else {
                // newInstance here
                return newRegexp(recv.getRuntime(), quote(recv,args).getByteList(), 0, false);
            }
        } else {
            KCode kcode = null;
            IRubyObject kcode_re = recv.getRuntime().getNil();
            RubyString source = recv.getRuntime().newString();
            IRubyObject[] _args = new IRubyObject[3];

            for (int i = 0; i < args.length; i++) {
View Full Code Here

Examples of org.jruby.util.KCode

       
        Map<String, NKFCharset> options = parseOpt(opt.convertToString().toString());
       
        NKFCharset nc = options.get("input");
        if (nc.getValue() == AUTO.getValue()) {
            KCode kcode = runtime.getKCode();
            if (kcode == KCode.SJIS) {
                nc = SJIS;
            } else if (kcode == KCode.EUC) {
                nc = EUC;
            } else if (kcode == KCode.UTF8) {
View Full Code Here

Examples of org.jruby.util.KCode

        ScriptingContainer instance = new ScriptingContainer(LocalContextScope.THREADSAFE);
        instance.setError(pstream);
        instance.setOutput(pstream);
        instance.setWriter(writer);
        instance.setErrorWriter(writer);
        KCode expResult = KCode.NONE;
        KCode result = instance.getKCode();
        assertEquals(expResult, result);

        instance = null;
    }
View Full Code Here

Examples of org.jruby.util.KCode

     * Test of setKCode method, of class ScriptingContainer.
     */
    @Test
    public void testSetKCode() {
        logger1.info("setKCode");
        KCode kcode = null;
        ScriptingContainer instance = new ScriptingContainer(LocalContextScope.SINGLETHREAD);
        instance.setError(pstream);
        instance.setOutput(pstream);
        instance.setWriter(writer);
        instance.setErrorWriter(writer);
View Full Code Here

Examples of org.jruby.util.KCode

        }

        Map<String, NKFCharset> options = parseOpt(opt.convertToString().toString());

        if (options.get("input").getValue() == AUTO.getValue()) {
            KCode kcode = runtime.getKCode();
            if (kcode == KCode.SJIS) {
                options.put("input", SJIS);
            } else if (kcode == KCode.EUC) {
                options.put("input", EUC);
            } else if (kcode == KCode.UTF8) {
View Full Code Here

Examples of org.jruby.util.KCode

     *
     */
    @JRubyMethod(name = {"quote", "escape"}, required = 1, optional = 1, meta = true, compat = CompatVersion.RUBY1_8)
    public static RubyString quote(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
        Ruby runtime = context.getRuntime();
        final KCode code;
        if (args.length == 1 || args[1].isNil()) {
            code = runtime.getKCode();
        } else {
            code = KCode.create(runtime, args[1].toString());
        }

        RubyString src = args[0].convertToString();
        RubyString dst = RubyString.newStringShared(runtime, quote(src.getByteList(), code.getEncoding()));
        dst.infectBy(src);
        return dst;
    }
View Full Code Here

Examples of org.jruby.util.KCode

            for(int i = 0; i<len; i++) {
                realArgs[i] = aa.entry(i);
            }
        }

        KCode kcode = null;
        IRubyObject kcode_re = runtime.getNil();
        RubyString source = runtime.newString();

        for (int i = 0; i < realArgs.length; i++) {
            if (0 < i) source.cat((byte)'|');
View Full Code Here

Examples of org.jruby.util.KCode

            }
        }
    }
   
    private void setKCode(String encoding) {
        KCode kcode = KCode.create(runtime, encoding);
        runtime.setKCode(kcode);
    }
View Full Code Here

Examples of org.jruby.util.KCode

     *
     */
    @JRubyMethod(name = {"quote", "escape"}, required = 1, optional = 1, meta = true, compat = CompatVersion.RUBY1_8)
    public static RubyString quote(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
        Ruby runtime = context.runtime;
        final KCode code;
        if (args.length == 1 || args[1].isNil()) {
            code = runtime.getKCode();
        } else {
            code = KCode.create(runtime, args[1].toString());
        }

        RubyString src = args[0].convertToString();
        RubyString dst = RubyString.newStringShared(runtime, quote(src.getByteList(), code.getEncoding()));
        dst.infectBy(src);
        return dst;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.