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

Default charset for PrintWriter that wraps PrintStream

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 18
    • Fix Version/s: 18
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b25
    • CPU:
      generic
    • OS:
      generic

      Description

      This issue was raised during the conversations in the following PR:
      https://github.com/openjdk/jdk/pull/5771
      The constructors that take `OutputStream` w/o explicit charset defaults to use the `Charset.defaultCharset()` encoding. This is causing an issue if the OutputStream to wrap is a PrintStream, which holds its own charset, and it will be ignored. If those charsets differ, apps would end up specifying explicit charset on creating the PrintWriter, as in the said PR.
      This is especially problematic when PrintWriter wraps System.out/err, because with the JEP400, the default charset is now UTF-8 while standard I/O remains in `native.encoding`.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              naoto Naoto Sato
              Reporter:
              naoto Naoto Sato
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: