示例#1
0
 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()];
 }
 @JRubyMethod
 public IRubyObject convpath(ThreadContext context) {
   // we always pass through UTF-16
   IRubyObject utf16Encoding =
       context.runtime.getEncodingService().getEncodingList()[UTF16.getIndex()];
   return RubyArray.newArray(
       context.runtime,
       RubyArray.newArray(context.runtime, srcEncoding, utf16Encoding),
       RubyArray.newArray(context.runtime, utf16Encoding, destEncoding));
 }
示例#3
0
 @JRubyMethod
 public IRubyObject convpath(ThreadContext context) {
   Ruby runtime = context.runtime;
   EncodingService encodingService = runtime.getEncodingService();
   // we always pass through UTF-16
   IRubyObject utf16Encoding = encodingService.getEncodingList()[UTF16.getIndex()];
   return RubyArray.newArray(
       runtime,
       RubyArray.newArray(runtime, source_encoding(context), utf16Encoding),
       RubyArray.newArray(runtime, utf16Encoding, destination_encoding(context)));
 }
示例#4
0
 public Encoding loadEncoding(ByteList name) {
   Entry entry = findEncodingOrAliasEntry(name);
   if (entry == null) return null;
   Encoding enc = entry.getEncoding(); // load the encoding
   int index = enc.getIndex();
   if (index >= encodingIndex.length) {
     RubyEncoding tmp[] = new RubyEncoding[index + 4];
     System.arraycopy(encodingIndex, 0, tmp, 0, encodingIndex.length);
     encodingIndex = tmp;
   }
   encodingIndex[index] = (RubyEncoding) encodingList[entry.getIndex()];
   return enc;
 }