Skip to content
Browse files

Fix JRUBY-5940: StringIO#set_encoding is not implemented

  • Loading branch information...
1 parent 422b6c7 commit 089616ffcd9ebc2e17717357a96413c8d387d412 @headius headius committed Aug 16, 2011
Showing with 18 additions and 0 deletions.
  1. +18 −0 src/org/jruby/RubyStringIO.java
View
18 src/org/jruby/RubyStringIO.java
@@ -44,6 +44,7 @@
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.ThreadContext;
import static org.jruby.runtime.Visibility.*;
+import static org.jruby.CompatVersion.*;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
import org.jruby.util.TypeConverter;
@@ -996,6 +997,23 @@ private int writeInternal(ThreadContext context, IRubyObject arg) {
return val.getByteList().length();
}
+
+ @JRubyMethod(compat = RUBY1_9)
+ public IRubyObject set_encoding(ThreadContext context, IRubyObject enc) {
+ Encoding encoding = context.runtime.getEncodingService().getEncodingFromObject(enc);
+ data.internal.setEncoding(encoding);
+ return this;
+ }
+
+ @JRubyMethod(compat = RUBY1_9)
+ public IRubyObject external_encoding(ThreadContext context) {
+ return context.runtime.getEncodingService().convertEncodingToRubyEncoding(data.internal.getEncoding());
+ }
+
+ @JRubyMethod(compat = RUBY1_9)
+ public IRubyObject internal_encoding(ThreadContext context) {
+ return context.nil;
+ }
/* rb: check_modifiable */
@Override

0 comments on commit 089616f

Please sign in to comment.
Something went wrong with that request. Please try again.