Skip to content
Browse files

Fixes #1198. Strings not printed properly to windows console

  • Loading branch information...
1 parent e31e853 commit 5bd07983d52bd886cc2bb292d60de0826c7f2b2c @enebo enebo committed Dec 4, 2013
Showing with 8 additions and 1 deletion.
  1. +8 −1 core/src/main/java/org/jruby/RubyIO.java
View
9 core/src/main/java/org/jruby/RubyIO.java
@@ -1459,9 +1459,16 @@ protected int fwrite(RubyString buffer) {
}
int len = buffer.size();
-
+
if ((n = len) <= 0) return n;
+ // console() can detect underlying windows codepage so we will just write to it
+ // and hope it is legible.
+ if (Platform.IS_WINDOWS && tty_p(getRuntime().getCurrentContext()).isTrue()) {
+ System.console().printf("%s", buffer.asJavaString());
+ return len;
+ }
+
try {
if (openFile.isSync()) {
openFile.fflush(writeStream);

0 comments on commit 5bd0798

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