On Thu, 18 Nov 2021 00:11:49 GMT, Naoto Sato <na...@openjdk.org> wrote:

> > BTW, I still observe on Windows (system locale=ja-JP):
> > ```
> > D:\projects\jdk\git\jdk>.\build\windows-x64\jdk\bin\jshell 
> > -J-Duser.language=ja
> > |  JShellへようこそ -- バージョン18-internal
> > |  概要については、次を入力してください: /help intro
> > 
> > jshell> System.out.println("\u3042")
> > 縺・
> > ```
> > This needs to be separately addressed in 
> > https://bugs.openjdk.java.net/browse/JDK-8274784
> 
> The following diff seems to fix the garbled char issue above:
> 
> ```
> $ git diff
> diff --git 
> a/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java
>  
> b/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java
> index 810e80acf47..be0b9dcb0c3 100644
> --- 
> a/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java
> +++ 
> b/src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java
> @@ -30,6 +30,7 @@ import java.io.PrintStream;
>  import java.lang.reflect.Method;
>  import java.net.Socket;
> 
> +import java.nio.charset.Charset;
>  import java.util.HashMap;
>  import java.util.Map;
>  import java.util.function.Consumer;
> @@ -63,8 +64,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, 
> Charset.forName(System.getProperty("native.encoding")))));
> +        outputs.put("err", st -> System.setErr(new PrintStream(st, true, 
> Charset.forName(System.getProperty("native.encoding")))));
>          Map<String, Consumer<InputStream>> input = new HashMap<>();
>          input.put("in", System::setIn);
>          forwardExecutionControlAndIO(new RemoteExecutionControl(), inStream, 
> outStream, outputs, input);
> ```

Many thanks, @naotoj .
It's good idea !.
By this code change, we just touch RemoteExecutionControl.java and encoding 
issue on jshell may be OK.
I'd like to discuss it on #5771 .

-------------

PR: https://git.openjdk.java.net/jdk/pull/6401

Reply via email to