New candidate JEP: 400: UTF-8 by Default
https://openjdk.java.net/jeps/400 Summary: Use UTF-8 as the JDK's default charset, so that APIs that depend on the default charset behave consistently across all platforms and independently of the user’s locale and configuration. - Mark
I like it. The only thing which I feel is missing would be an official API to get the operating environments default encoding (essentially to get the value used if COMPAT would have been specified). For example, in our server application, we do have some code which is specified as using exactly this charset (I.e. if user configures targetEncoding=PLATFORM we are using intentionally the no-arg APIs). We can change that code to specify a Charset, but then we need a way to retrieve that - without poking into unsupported system properties or environment properties. For example System.platformCharset(). I understand that this might have it’s own complications - as not all OS have this concept (for example on Windows there might be different codepages depending on the unicode status of an application). But falling back to today’s file.encoding code would at least be consistent and the behavior most implementer would desire when adapting legacy code to this JEP. Gruss Bernd -- http://bernd.eckenfels.net ________________________________ Von: core-libs-dev <core-libs-dev-retn@openjdk.java.net> im Auftrag von mark.reinhold@oracle.com <mark.reinhold@oracle.com> Gesendet: Thursday, March 11, 2021 1:27:05 AM An: naoto.sato@oracle.com <naoto.sato@oracle.com> Cc: core-libs-dev@openjdk.java.net <core-libs-dev@openjdk.java.net>; jdk-dev@openjdk.java.net <jdk-dev@openjdk.java.net> Betreff: New candidate JEP: 400: UTF-8 by Default https://openjdk.java.net/jeps/400 Summary: Use UTF-8 as the JDK's default charset, so that APIs that depend on the default charset behave consistently across all platforms and independently of the user’s locale and configuration. - Mark
----- Mail original -----
De: "Bernd Eckenfels" <ecki@zusammenkunft.net> À: "core-libs-dev" <core-libs-dev@openjdk.java.net> Cc: "jdk-dev" <jdk-dev@openjdk.java.net> Envoyé: Jeudi 11 Mars 2021 02:12:49 Objet: Re: New candidate JEP: 400: UTF-8 by Default
I like it. The only thing which I feel is missing would be an official API to get the operating environments default encoding (essentially to get the value used if COMPAT would have been specified).
For example, in our server application, we do have some code which is specified as using exactly this charset (I.e. if user configures targetEncoding=PLATFORM we are using intentionally the no-arg APIs). We can change that code to specify a Charset, but then we need a way to retrieve that - without poking into unsupported system properties or environment properties. For example System.platformCharset().
I understand that this might have it’s own complications - as not all OS have this concept (for example on Windows there might be different codepages depending on the unicode status of an application). But falling back to today’s file.encoding code would at least be consistent and the behavior most implementer would desire when adapting legacy code to this JEP.
Hi, FileReader has a method named getEncoding()
Gruss Bernd -- http://bernd.eckenfels.net
regards, Rémi
Hello, Thanks for the hint. The question is if this would return UTF-8 after the JEP is implemented or not (should probably be mentioned in the JEP). If it keeps returning the legacy/platform file encoding that would be a good API for my purpose (but sounds like that would be rather confusing in regards to the default constructor) -- http://bernd.eckenfels.net ________________________________ Von: Remi Forax <forax@univ-mlv.fr> Gesendet: Thursday, March 11, 2021 2:19:19 AM An: Bernd Eckenfels <ecki@zusammenkunft.net> Cc: core-libs-dev <core-libs-dev@openjdk.java.net>; jdk-dev <jdk-dev@openjdk.java.net> Betreff: Re: New candidate JEP: 400: UTF-8 by Default ----- Mail original -----
De: "Bernd Eckenfels" <ecki@zusammenkunft.net> À: "core-libs-dev" <core-libs-dev@openjdk.java.net> Cc: "jdk-dev" <jdk-dev@openjdk.java.net> Envoyé: Jeudi 11 Mars 2021 02:12:49 Objet: Re: New candidate JEP: 400: UTF-8 by Default
I like it. The only thing which I feel is missing would be an official API to get the operating environments default encoding (essentially to get the value used if COMPAT would have been specified).
For example, in our server application, we do have some code which is specified as using exactly this charset (I.e. if user configures targetEncoding=PLATFORM we are using intentionally the no-arg APIs). We can change that code to specify a Charset, but then we need a way to retrieve that - without poking into unsupported system properties or environment properties. For example System.platformCharset().
I understand that this might have it’s own complications - as not all OS have this concept (for example on Windows there might be different codepages depending on the unicode status of an application). But falling back to today’s file.encoding code would at least be consistent and the behavior most implementer would desire when adapting legacy code to this JEP.
Hi, FileReader has a method named getEncoding()
Gruss Bernd -- http://bernd.eckenfels.net
regards, Rémi
participants (3)
-
Bernd Eckenfels
-
mark.reinhold@oracle.com
-
Remi Forax