Skip to content

Commit 164856c

Browse files
committed
Ensure print/say ops on JVM write UTF-8.
Fixes issues with CORE.setting generation some folks have been seeing.
1 parent bc60762 commit 164856c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/vm/jvm/runtime/org/perl6/nqp/runtime/GlobalContext.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.InputStream;
44
import java.io.PrintStream;
5+
import java.io.UnsupportedEncodingException;
56
import java.lang.ref.WeakReference;
67
import java.util.HashMap;
78
import java.util.HashSet;
@@ -186,9 +187,9 @@ public class GlobalContext {
186187
public ByteClassLoader byteClassLoader;
187188

188189
/** Redirected output for eval-server. */
189-
public PrintStream out = System.out;
190+
public PrintStream out;
190191
/** Redirected error for eval-server. */
191-
public PrintStream err = System.err;
192+
public PrintStream err;
192193
/** Redirected input for eval-server. */
193194
public InputStream in = System.in;
194195
/** Whether to disallow exit. */
@@ -217,6 +218,14 @@ public class GlobalContext {
217218
*/
218219
public GlobalContext()
219220
{
221+
try {
222+
out = new PrintStream(System.out, true, "UTF-8");
223+
err = new PrintStream(System.err, true, "UTF-8");
224+
}
225+
catch (UnsupportedEncodingException e) {
226+
throw new RuntimeException(e);
227+
}
228+
220229
compileeHLLConfiguration = new HashMap<String, HLLConfig>();
221230
hllConfiguration = compileeHLLConfiguration;
222231
getHLLConfigFor("");

0 commit comments

Comments
 (0)