8274784: jshell: Garbled character was displayed by System.out.println(...) on Japanese Windows

Reviewed-by: naoto
This commit is contained in:
Ichiroh Takiguchi 2021-11-29 00:11:28 +00:00
parent e9b36a8316
commit 8f9eb620ac
2 changed files with 4 additions and 4 deletions

View File

@ -55,7 +55,7 @@ public abstract class AbstractTerminal implements Terminal {
public AbstractTerminal(String name, String type, Charset encoding, SignalHandler signalHandler) throws IOException {
this.name = name;
this.type = type != null ? type : "ansi";
this.encoding = encoding != null ? encoding : Charset.defaultCharset();
this.encoding = encoding != null ? encoding : System.out.charset();
for (Signal signal : Signal.values()) {
handlers.put(signal, signalHandler);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -63,8 +63,8 @@ public class RemoteExecutionControl extends DirectExecutionControl implements Ex
InputStream inStream = socket.getInputStream();
OutputStream outStream = socket.getOutputStream();
Map<String, Consumer<OutputStream>> outputs = new HashMap<>();
outputs.put("out", st -> System.setOut(new PrintStream(st, true)));
outputs.put("err", st -> System.setErr(new PrintStream(st, true)));
outputs.put("out", st -> System.setOut(new PrintStream(st, true, System.out.charset())));
outputs.put("err", st -> System.setErr(new PrintStream(st, true, System.err.charset())));
Map<String, Consumer<InputStream>> input = new HashMap<>();
input.put("in", System::setIn);
forwardExecutionControlAndIO(new RemoteExecutionControl(), inStream, outStream, outputs, input);