IRubyObject key = unmarshalObject(false);
if (i == 0) { // first ivar
if (runtime.is1_9()
&& (object instanceof RubyString || object instanceof RubyRegexp)
&& count >= 1) { // 1.9 string encoding
EncodingCapable strObj = (EncodingCapable)object;
if (key.asJavaString().equals(MarshalStream.SYMBOL_ENCODING_SPECIAL)) {
// special case for USASCII and UTF8
if (unmarshalObject().isTrue()) {
strObj.setEncoding(UTF8Encoding.INSTANCE);
} else {
strObj.setEncoding(USASCIIEncoding.INSTANCE);
}
continue;
} else if (key.asJavaString().equals("encoding")) {
// read off " byte for the string
read();
ByteList encodingName = unmarshalString();
Entry entry = runtime.getEncodingService().findEncodingOrAliasEntry(encodingName);
if (entry == null) {
throw runtime.newArgumentError("invalid encoding in marshaling stream: " + encodingName);
}
Encoding encoding = entry.getEncoding();
strObj.setEncoding(encoding);
continue;
} // else fall through as normal ivar
}
}
String name = key.asJavaString();