Package org.jruby

Examples of org.jruby.RubyString.force_encoding()


    private RubyString reinterpretEncoding(ThreadContext context,
            RubyString str, String sniffedEncoding) {
        RubyEncoding actualEncoding = info.getEncoding(context, sniffedEncoding);
        RubyEncoding targetEncoding = info.utf8.get();
        RubyString dup = (RubyString)str.dup();
        dup.force_encoding(context, actualEncoding);
        return (RubyString)dup.encode_bang(context, targetEncoding);
    }

    /**
     * <code>Parser#parse()</code>
 
View Full Code Here


            {
                case 1:
                    output.setEncodingAndCodeRange(USASCII, RubyObject.USER8_F);
                    break;
                case 2:
                    output.force_encoding(runtime.getCurrentContext(),
                            runtime.getEncodingService().convertEncodingToRubyEncoding(UTF8));
                    break;
                default:
                    /* do nothing, keep ASCII-8BIT */
            }
View Full Code Here

    private RubyString reinterpretEncoding(ThreadContext context,
            RubyString str, String sniffedEncoding) {
        RubyEncoding actualEncoding = info.getEncoding(context, sniffedEncoding);
        RubyEncoding targetEncoding = info.utf8.get();
        RubyString dup = (RubyString)str.dup();
        dup.force_encoding(context, actualEncoding);
        return (RubyString)dup.encode_bang(context, targetEncoding);
    }

    /**
     * <code>Parser#parse()</code>
 
View Full Code Here

            generate(session, object, buffer);
            result = RubyString.newString(session.getRuntime(), buffer);
            ThreadContext context = session.getContext();
            RuntimeInfo info = session.getInfo();
            if (info.encodingsSupported()) {
                result.force_encoding(context, info.utf8.get());
            }
            return result;
        }

        abstract void generate(Session session, T object, ByteList buffer);
View Full Code Here

            throw Utils.newException(context, Utils.M_GENERATOR_ERROR,
                    "only generation of JSON objects or arrays allowed");
        }
        RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
        if (info.encodingsSupported()) {
            result.force_encoding(context, info.utf8.get());
        }
        return result;
    }

    /**
 
View Full Code Here

            {
                case 1:
                    output.setEncodingAndCodeRange(USASCII, RubyObject.USER8_F);
                    break;
                case 2:
                    output.force_encoding(runtime.getCurrentContext(),
                            runtime.getEncodingService().convertEncodingToRubyEncoding(UTF8));
                    break;
                default:
                    /* do nothing, keep ASCII-8BIT */
            }
View Full Code Here

    private RubyString reinterpretEncoding(ThreadContext context,
            RubyString str, String sniffedEncoding) {
        RubyEncoding actualEncoding = info.getEncoding(context, sniffedEncoding);
        RubyEncoding targetEncoding = info.utf8.get();
        RubyString dup = (RubyString)str.dup();
        dup.force_encoding(context, actualEncoding);
        return (RubyString)dup.encode_bang(context, targetEncoding);
    }

    /**
     * <code>Parser#parse()</code>
 
View Full Code Here

            throw Utils.newException(context, Utils.M_GENERATOR_ERROR,
                    "only generation of JSON objects or arrays allowed");
        }
        RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
        if (info.encodingsSupported()) {
            result.force_encoding(context, info.utf8.get());
        }
        return result;
    }

    /**
 
View Full Code Here

    private RubyString reinterpretEncoding(ThreadContext context,
            RubyString str, String sniffedEncoding) {
        RubyEncoding actualEncoding = info.getEncoding(context, sniffedEncoding);
        RubyEncoding targetEncoding = info.utf8.get();
        RubyString dup = (RubyString)str.dup();
        dup.force_encoding(context, actualEncoding);
        return (RubyString)dup.encode_bang(context, targetEncoding);
    }

    /**
     * <code>Parser#parse()</code>
 
View Full Code Here

            throw Utils.newException(context, Utils.M_GENERATOR_ERROR,
                    "only generation of JSON objects or arrays allowed");
        }
        RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
        if (info.encodingsSupported()) {
            result.force_encoding(context, info.utf8.get());
        }
        return result;
    }

    /**
 
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.