Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8356936

Add inputCharset() to java.io.Console

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      openjdk 21.0.3 2024-04-16 LTS
      OpenJDK Runtime Environment Temurin-21.0.3+9 (build 21.0.3+9-LTS)
      OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS, mixed mode, sharing)

      Windows 24H2

      I read https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/io/Console.html and confirmed such a method doesn't exist in Java 24.

      A DESCRIPTION OF THE PROBLEM :
      There are some environments where the encodings of stdin and stdout are different (especially in Windows).

      ```pwsh
      [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
      [Console]::InputEncoding = [System.Text.Encoding]::GetEncoding(437)
      ```

      In such environments, you have to verbosely write`Charset.forName(System.getProperty("stdin.encoding"))` instead of the simple `System.console().charset()`.
      Now that we have stdin.encoding property today (JDK-8355357), we should have this `inputCharset()` method, too. It is just `stdin.encoding` - `stdout.encoding` + `charset()`.


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: