/** * Find an encoding given a Ruby object, coercing it to a String in the process. * This version does not raise a Ruby error if it can't find the encoding, * and simply returns null. * * @param str the object to coerce and use to look up encoding. The coerced String * must be ASCII-compatible. * @return the Encoding object found, nil (for internal) */ public Encoding findEncodingNoError(IRubyObject str) { return findEncodingCommon(str, false); }
/** * Find an encoding given a Ruby object, coercing it to a String in the process. * This version does not raise a Ruby error if it can't find the encoding, * and simply returns null. * * @param str the object to coerce and use to look up encoding. The coerced String * must be ASCII-compatible. * @return the Encoding object found, nil (for internal) */ public Encoding findEncodingNoError(IRubyObject str) { return findEncodingCommon(str, false); }
/** * Find an encoding given a Ruby object, coercing it to a String in the process. * This version does not raise a Ruby error if it can't find the encoding, * and simply returns null. * * @param str the object to coerce and use to look up encoding. The coerced String * must be ASCII-compatible. * @return the Encoding object found, nil (for internal), or raises ArgumentError */ public Encoding findEncodingNoError(IRubyObject str) { return findEncodingCommon(str, false); }
/** * Find an encoding given a Ruby object, coercing it to a String in the process. * * @param str the object to coerce and use to look up encoding. The coerced String * must be ASCII-compatible. * @return the Encoding object found, nil (for internal), or raises ArgumentError */ public Encoding findEncoding(IRubyObject str) { return findEncodingCommon(str, true); }
/** * Find an encoding given a Ruby object, coercing it to a String in the process. * This version does not raise a Ruby error if it can't find the encoding, * and simply returns null. * * @param str the object to coerce and use to look up encoding. The coerced String * must be ASCII-compatible. * @return the Encoding object found, nil (for internal), or raises ArgumentError */ public Encoding findEncodingNoError(IRubyObject str) { return findEncodingCommon(str, false); }
/** * Find an encoding given a Ruby object, coercing it to a String in the process. * * @param str the object to coerce and use to look up encoding. The coerced String * must be ASCII-compatible. * @return the Encoding object found, nil (for internal), or raises ArgumentError */ public Encoding findEncoding(IRubyObject str) { return findEncodingCommon(str, true); }
/** * Find an encoding given a Ruby object, coercing it to a String in the process. * * @param str the object to coerce and use to look up encoding. The coerced String * must be ASCII-compatible. * @return the Encoding object found, nil (for internal), or raises ArgumentError */ public Encoding findEncoding(IRubyObject str) { return findEncodingCommon(str, true); }
/** * Find an encoding given a Ruby object, coercing it to a String in the process. * * @param str the object to coerce and use to look up encoding. The coerced String * must be ASCII-compatible. * @return the Encoding object found, nil (for internal), or raises ArgumentError */ public Encoding findEncoding(IRubyObject str) { return findEncodingCommon(str, true); }
public Encoding findEncodingNoError(ByteList str) { return findEncodingCommon(str, false); }
public Encoding findEncodingNoError(ByteList str) { return findEncodingCommon(str, false); }
private Encoding findEncodingCommon(IRubyObject str, boolean error) { ByteList name = str.convertToString().getByteList(); return findEncodingCommon(name, error); }
private Encoding findEncodingCommon(IRubyObject str, boolean error) { ByteList name = str.convertToString().getByteList(); return findEncodingCommon(name, error); }
private Encoding getEncodingFromObjectCommon(IRubyObject arg, boolean error) { if (arg == null) return null; if (arg instanceof RubyEncoding) { return ((RubyEncoding) arg).getEncoding(); } if (arg instanceof RubyFixnum) { final int id = (int) arg.convertToInteger().getLongValue(); final String name = RubyNKF.NKFCharsetMap.get(id); if ( name != null ) return getEncodingFromNKFName(name); } if ( ( arg = arg.checkStringType() ).isNil() ) { return null; } if ( ! ((RubyString) arg).getEncoding().isAsciiCompatible() ) { return null; } return findEncodingCommon(((RubyString) arg).getByteList(), error); }
private Encoding getEncodingFromObjectCommon(IRubyObject arg, boolean error) { if (arg == null) return null; if (arg instanceof RubyEncoding) { return ((RubyEncoding) arg).getEncoding(); } if (arg instanceof RubyFixnum) { final int id = (int) arg.convertToInteger().getLongValue(); final String name = RubyNKF.NKFCharsetMap.get(id); if ( name != null ) return getEncodingFromNKFName(name); } if ( ( arg = arg.checkStringType() ).isNil() ) { return null; } if ( ! ((RubyString) arg).getEncoding().isAsciiCompatible() ) { return null; } return findEncodingCommon(((RubyString) arg).getByteList(), error); }