/** * 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 Entry findEncodingOrAliasEntry(ByteList bytes) { Entry e = findEncodingEntry(bytes); return e != null ? e : findAliasEntry(bytes); }
private static boolean shouldMarshalEncoding(IRubyObject value) { if (!(value instanceof MarshalEncoding)) return false; return ((MarshalEncoding) value).shouldMarshalEncoding(); }
private Encoding findEncodingCommon(ByteList name, boolean error) { checkAsciiEncodingName(name); SpecialEncoding special = SpecialEncoding.valueOf(name); if (special != null) { return special.toEncoding(runtime); } if (error) return findEncodingWithError(name); Entry e = findEncodingOrAliasEntry(name); if (e == null) return null; return e.getEncoding(); }
private Encoding findEncodingCommon(ByteList name, boolean error) { checkAsciiEncodingName(name); SpecialEncoding special = SpecialEncoding.valueOf(name); if (special != null) { return special.toEncoding(runtime); } if (error) return findEncodingWithError(name); Entry e = findEncodingOrAliasEntry(name); if (e == null) return null; return e.getEncoding(); }
public Entry findEncodingOrAliasEntry(byte[] bytes) { Entry e = findEncodingEntry(bytes); return e != null ? e : findAliasEntry(bytes); }
/** * 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); }
private static boolean shouldMarshalEncoding(IRubyObject value) { if (!(value instanceof MarshalEncoding)) return false; return ((MarshalEncoding) value).shouldMarshalEncoding(); }
public Encoding getEncodingFromString(String string) { if (string == null) return null; ByteList name = new ByteList(ByteList.plain(string), false); checkAsciiEncodingName(name); SpecialEncoding special = SpecialEncoding.valueOf(name); if (special != null) { return special.toEncoding(runtime); } return findEncodingWithError(name); }
public Entry findEncodingOrAliasEntry(byte[] bytes) { Entry e = findEncodingEntry(bytes); return e != null ? e : findAliasEntry(bytes); }
/** * 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); }
public Encoding getEncodingFromString(String string) { if (string == null) return null; ByteList name = new ByteList(ByteList.plain(string), false); checkAsciiEncodingName(name); SpecialEncoding special = SpecialEncoding.valueOf(name); if (special != null) { return special.toEncoding(runtime); } return findEncodingWithError(name); }
public Entry findEncodingOrAliasEntry(ByteList bytes) { Entry e = findEncodingEntry(bytes); return e != null ? e : findAliasEntry(bytes); }
/** * 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 getEncodingFromString(String string) { if (string == null) return null; ByteList name = new ByteList(ByteList.plain(string)); checkAsciiEncodingName(name); SpecialEncoding special = SpecialEncoding.valueOf(name); if (special != null) { return special.toEncoding(runtime); } return findEncodingWithError(name); }
/** * 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); }
public Encoding getEncodingFromString(String string) { if (string == null) return null; ByteList name = new ByteList(ByteList.plain(string)); checkAsciiEncodingName(name); SpecialEncoding special = SpecialEncoding.valueOf(name); if (special != null) { return special.toEncoding(runtime); } return findEncodingWithError(name); }
/** * 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); }