<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    On 20/10/2022 01:05, Reinier Zwitserloot wrote:<br>
    <blockquote type="cite" cite="mid:CAK6PxWNw+Q_6Q=SJxQRNg+DcVPUvkCYwu1mHahrUYbbfF2G8RA@mail.gmail.com">
      
      :
      <div dir="ltr"><br>
      </div>
      <div dir="ltr"><br>
      </div>
      JDK18 brought JEP400 which changes the default charset encoding to
      UTF-8. This, probably out of necessity, goes quite far, in that <code style="border:1px solid
        rgb(206,206,206);background-color:rgb(244,244,244);padding:0px
2px;border-top-left-radius:2px;border-top-right-radius:2px;border-bottom-right-radius:2px;border-bottom-left-radius:2px">Charset.defaultCharset()</code> is
      now more or less a constant - always returns UTF_8. It’s now quite
      difficult to retrieve the OS-configured encoding (the ’native’
      encoding).
      <div><br>
      </div>
      <div dir="ltr">However, that does mean one of the most common
        lines in all of java’s history, is now necessarily buggy: <code style="border:1px solid
          rgb(206,206,206);background-color:rgb(244,244,244);padding:0px
2px;border-top-left-radius:2px;border-top-right-radius:2px;border-bottom-right-radius:2px;border-bottom-left-radius:2px">new
          Scanner(System.in)</code> is now broken.<br>
      </div>
    </blockquote>
    <br>
    System.in has always been problematic, including new
    Scanner(System.in), as it could be connected to anything.<br>
    <br>
    As Ron noted, Console (since Java 6) provides readLine, reader, and
    printf so it's not bad for reading and writing lines of text,
    something that will be typical when starting out. Yes, Console is
    problematic for tooling that takes ownership of the console. We've
    been mulling over introducing a SPI for that - if you back through
    the archives then you'll see some early discussion on that. If the
    JDK has a SPI then it would mean that jshell and IDEs would be able
    to provide an implementation that works in respective environments
    and so provide a better experience for code that uses
    System.console.<br>
    <br>
    You are right that further work is required to move away from using
    System.in directly.  JDK-8295672 [1] is tracking some of the ideas
    for possible APIs. The focus is a bit different to your list as we
    don't want to expose the notion of Charsets to new users nor provide
    APIs like System.charIn that wouldn't support reading lines or work
    with redirection. Prototypes and experimentation will required to
    find the right API to propose.<br>
    <br>
    -Alan<br>
    <br>
    [1] <a class="moz-txt-link-freetext" href="https://bugs.openjdk.org/browse/JDK-8295672">https://bugs.openjdk.org/browse/JDK-8295672</a><br>
  </body>
</html>