RFR: 8234835 Use UTF-8 charset in make support Java code
Martin Buchholz
martinrb at google.com
Wed Dec 4 23:52:48 UTC 2019
Looks good ... but please add a comment pointing to
https://pandoc.org/MANUAL.html
"""Pandoc uses the UTF-8 character encoding for both input and output."""
On Wed, Dec 4, 2019 at 3:30 PM Dan Smith <daniel.smith at oracle.com> wrote:
> > On Dec 3, 2019, at 5:24 PM, Jonathan Gibbons <
> jonathan.gibbons at oracle.com> wrote:
> >
> > Hi Dan,
> >
> > I think it's a combination of oral tradition and long-standing precedent.
> >
> > Earlier this year, I raised this general issue, partly because of
> inconsistent use of -encoding in the build system. The response was that
> there was some concern that not all tools in the tool chain could handle
> UTF-8 files.
> >
> > $ find open/make -name \*.gmk | xargs grep -o -e '-encoding [^ ]*'
> > open/make/Docs.gmk:-encoding ISO-8859-1
> > open/make/Docs.gmk:-encoding ISO-8859-1
> > open/make/common/SetupJavaCompilers.gmk:-encoding ascii
> > open/make/common/SetupJavaCompilers.gmk:-encoding ascii
> >
> > I think we should be consistent, but (at the time) it did not seem worth
> pushing for UTF-8 everywhere.
>
> Yeah, I think I'll join you in not being ready for this crusade. Might be
> nice, but will require broad familiarity with everything in the JDK that
> touches text.
>
> Instead, I'm happy to assert that, within the small space of spec
> processing tools, we need to support UTF-8, and so target my changeset to
> just the fixuppandoc tool.
>
> Can I get a review on this specific change?:
>
> -----
>
> diff -r 8c4c358272a9 -r 4c0e6c85037c
> make/jdk/src/classes/build/tools/fixuppandoc/Main.java
> --- a/make/jdk/src/classes/build/tools/fixuppandoc/Main.java Fri Nov 15
> 20:39:26 2019 +0800
> +++ b/make/jdk/src/classes/build/tools/fixuppandoc/Main.java Wed Dec 04
> 16:24:25 2019 -0700
> @@ -46,6 +46,7 @@
> import java.util.Set;
> import java.util.regex.Matcher;
> import java.util.regex.Pattern;
> +import static java.nio.charset.StandardCharsets.UTF_8;
>
> /**
> * Fixup HTML generated by pandoc.
> @@ -184,7 +185,7 @@
> if (inFile != null) {
> read(inFile);
> } else {
> - read(new BufferedReader(new
> InputStreamReader(System.in)));
> + read(new BufferedReader(new
> InputStreamReader(System.in, UTF_8)));
> }
> }
> }
> @@ -198,9 +199,9 @@
> */
> private Writer openWriter(Path file) throws IOException {
> if (file != null) {
> - return Files.newBufferedWriter(file);
> + return Files.newBufferedWriter(file, UTF_8);
> } else {
> - return new BufferedWriter(new
> OutputStreamWriter(System.out) {
> + return new BufferedWriter(new
> OutputStreamWriter(System.out, UTF_8) {
> @Override
> public void close() throws IOException {
> flush();
> @@ -615,7 +616,7 @@
> * @param file the file
> */
> void read(Path file) {
> - try (Reader r = Files.newBufferedReader(file)) {
> + try (Reader r = Files.newBufferedReader(file, UTF_8)) {
> this.file = file;
> read(r);
> } catch (IOException e) {
>
>
More information about the build-dev
mailing list