private int cacheEncodingInternal(Encoding encoding) { String encodingName = new String(encoding.getName()); Integer index = encodingIndices.get(encodingName); if (index == null) { index = Integer.valueOf(inheritedEncodingCount++); encodingIndices.put(encodingName, index); } return index; }
private int cacheEncodingInternal(Encoding encoding) { String encodingName = new String(encoding.getName()); Integer index = encodingIndices.get(encodingName); if (index == null) { index = Integer.valueOf(inheritedEncodingCount++); encodingIndices.put(encodingName, index); } return index; }
protected void ecopts(ThreadContext context, IRubyObject opts) { if (!opts.isNil()) { EncodingUtils.ioExtractEncodingOption(context, this, opts, null); } if (enc2 != null) { IRubyObject[] outOpts = new IRubyObject[]{opts}; ecflags = EncodingUtils.econvPrepareOpts(context, opts, outOpts); ec = EncodingUtils.econvOpenOpts(context, enc.getName(), enc2.getName(), ecflags, opts); ecopts = opts; } }
protected void ecopts(ThreadContext context, IRubyObject opts) { if (!opts.isNil()) { EncodingUtils.ioExtractEncodingOption(context, this, opts, null); } if (enc2 != null) { IRubyObject[] outOpts = new IRubyObject[]{opts}; ecflags = EncodingUtils.econvPrepareOpts(context, opts, outOpts); ec = EncodingUtils.econvOpenOpts(context, enc.getName(), enc2.getName(), ecflags, opts); ecopts = opts; } }
private Entry findEntryFromEncoding(Encoding e) { if (e == null) return null; return findEncodingEntry(new ByteList(e.getName())); } }
protected void ecopts(ThreadContext context, IRubyObject opts) { if (!opts.isNil()) { EncodingUtils.ioExtractEncodingOption(context, this, opts, null); } if (enc2 != null) { IRubyObject[] outOpts = new IRubyObject[]{opts}; ecflags = EncodingUtils.econvPrepareOpts(context, opts, outOpts); ec = EncodingUtils.econvOpenOpts(context, enc.getName(), enc2.getName(), ecflags, opts); ecopts = opts; } }
/** * Push a symbol on the stack * @param sym the symbol's string identifier */ public void pushSymbol(String sym, Encoding encoding) { loadContext(); adapter.invokedynamic("symbol", sig(JVM.OBJECT, ThreadContext.class), SymbolObjectSite.BOOTSTRAP, sym, new String(encoding.getName())); }
public static Encoding encArg(ThreadContext context, IRubyObject encval, byte[][] name_p, Encoding[] enc_p) { Encoding enc; if ((enc = toEncodingIndex(context, encval)) == null) { name_p[0] = encval.convertToString().getBytes(); } else { name_p[0] = enc.getName(); } return enc_p[0] = enc; }
public RubyEncoding getEncoding(Encoding enc) { int index = enc.getIndex(); RubyEncoding rubyEncoding; RubyEncoding[] encodingIndex = this.encodingIndex; if (index < encodingIndex.length && (rubyEncoding = encodingIndex[index]) != null) { return rubyEncoding; } // loadEncoding : Entry entry = findEncodingOrAliasEntry(enc.getName()); return loadEncodingEntry(entry); }
@JRubyMethod public static IRubyObject source_encoding_name(ThreadContext context, IRubyObject self) { RubyCoderResult result = (RubyCoderResult)self.dataGetStruct(); return RubyString.newString(context.runtime, result.inEncoding.getName()); }
public static Encoding encArg(ThreadContext context, IRubyObject encval, byte[][] name_p, Encoding[] enc_p) { if ((enc_p[0] = toEncodingIndex(context, encval)) == null) { name_p[0] = ((RubyString)encval.anyToString()).getBytes(); } else { name_p[0] = enc_p[0].getName(); } return enc_p[0]; }
public static Encoding encReplicate(ThreadContext context, byte[] name, Encoding encoding) { encCheckDuplication(context, name); EncodingDB.replicate(new String(name), new String(encoding.getName())); return EncodingDB.getEncodings().get(name).getEncoding(); }
public static Encoding encArg(ThreadContext context, IRubyObject encval, byte[][] name_p, Encoding[] enc_p) { Encoding enc; if ((enc = toEncodingIndex(context, encval)) == null) { name_p[0] = encval.convertToString().getBytes(); } else { name_p[0] = enc.getName(); } return enc_p[0] = enc; }
@JRubyMethod public static IRubyObject source_encoding_name(ThreadContext context, IRubyObject self) { RubyCoderResult result = (RubyCoderResult)self.dataGetStruct(); return RubyString.newString(context.runtime, result.inEncoding.getName()); }
public static Encoding strTranscodeEncArgs(ThreadContext context, IRubyObject str, IRubyObject arg1, IRubyObject arg2, byte[][] sname_p, Encoding[] senc_p, byte[][] dname_p, Encoding[] denc_p) { Encoding dencindex; dencindex = encArg(context, arg1, dname_p, denc_p); if (arg2.isNil()) { senc_p[0] = encGet(context, str); sname_p[0] = senc_p[0].getName(); } else { encArg(context, arg2, sname_p, senc_p); } return dencindex; }
public static Encoding strTranscodeEncArgs(ThreadContext context, IRubyObject str, IRubyObject arg1, IRubyObject arg2, byte[][] sname_p, Encoding[] senc_p, byte[][] dname_p, Encoding[] denc_p) { Encoding dencindex; dencindex = encArg(context, arg1, dname_p, denc_p); if (arg2.isNil()) { senc_p[0] = encGet(context, str); sname_p[0] = senc_p[0].getName(); } else { encArg(context, arg2, sname_p, senc_p); } return dencindex; }
public RubyEncoding getEncoding(Encoding enc) { int index = enc.getIndex(); RubyEncoding rubyEncoding; if (index < encodingIndex.length && (rubyEncoding = encodingIndex[index]) != null) { return rubyEncoding; } enc = loadEncoding(new ByteList(enc.getName(), false)); return encodingIndex[enc.getIndex()]; }
public RubyEncoding getEncoding(Encoding enc) { int index = enc.getIndex(); RubyEncoding rubyEncoding; if (index < encodingIndex.length && (rubyEncoding = encodingIndex[index]) != null) { return rubyEncoding; } enc = loadEncoding(new ByteList(enc.getName(), false)); return encodingIndex[enc.getIndex()]; }
public static Encoding strTranscodeEncArgs(ThreadContext context, IRubyObject str, IRubyObject arg1, IRubyObject arg2, byte[][] sname_p, Encoding[] senc_p, byte[][] dname_p, Encoding[] denc_p) { Encoding dencindex; dencindex = encArg(context, arg1, dname_p, denc_p); if (arg2.isNil()) { senc_p[0] = encGet(context, str); sname_p[0] = senc_p[0].getName(); } else { encArg(context, arg2, sname_p, senc_p); } return dencindex; }
@JRubyMethod(name = "locale_charmap", meta = true) public static IRubyObject locale_charmap(ThreadContext context, IRubyObject recv) { Ruby runtime = context.runtime; EncodingService service = runtime.getEncodingService(); ByteList name = new ByteList(service.getLocaleEncoding().getName()); return RubyString.newUsAsciiStringNoCopy(runtime, name); }