On Tue, 20 May 2025 10:40:39 GMT, Volkan Yazici <vyaz...@openjdk.org> wrote:

>> `java.io.Console` uses the charset specified by the `stdout.encoding` system 
>> property for both input and output. While this is generally sufficient, 
>> since Console is intended for interactive terminal use, some platforms allow 
>> different encodings to be configured for input and output. In such cases, 
>> using a single encoding may lead to incorrect behavior when reading from the 
>> terminal. To address this, the newly introduced system property, 
>> `stdin.encoding`, should be used specifically for input where appropriate.
>
> src/jdk.internal.le/share/classes/jdk/internal/org/jline/JdkConsoleProviderImpl.java
>  line 160:
> 
>> 158: 
>> 159:             try {
>> 160:                 Terminal terminal = 
>> TerminalBuilder.builder().encoding(outCharset)
> 
> Shouldn't ideally `JdkConsole::charset` and `Terminal::encoding` be adapted 
> for stdin/stdout variants?

Also noticed `DumbTerminalProvider::sysTerminal` calls `DumbTerminal` with `new 
FileInputStream(FileDescriptor.in)`. Later on `DumbTerminal` applies 
`encoding()` both for passed `stdin` and `std{out,err}`. In short, 
`TerminalProvider` might need to undergo a similar refactoring separating input 
and output encodings.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25271#discussion_r2098698322

Reply via email to