From a8eab70a29dc55514fd523371762d286ca7082df Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Fri, 5 Jan 2024 14:35:24 +0700 Subject: [PATCH] Bugfix: AspectJ installer extracts text files as US-ASCII MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When extracting text or HTML files, special characters like German umlauts "ÄÖÜäöüß" or copyright symbol "©" were destroyed while unpacking the installer archive. As our files in Git SCM are all UTF-8, the installer now also uses UTF-8 to read and write text files. Fixes #270. Signed-off-by: Alexander Kriegisch --- build/src/main/java/$installer$/org/aspectj/Main.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/build/src/main/java/$installer$/org/aspectj/Main.java b/build/src/main/java/$installer$/org/aspectj/Main.java index d11ba8f6b..068258311 100644 --- a/build/src/main/java/$installer$/org/aspectj/Main.java +++ b/build/src/main/java/$installer$/org/aspectj/Main.java @@ -67,6 +67,8 @@ import javax.swing.border.Border; import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * Invoke the Installer gui. There are two ways to run without GUI by passing parameters to main: *
    @@ -678,7 +680,7 @@ abstract class WizardPane { } public static String stringFromStream(InputStream stream) throws IOException { - BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "US-ASCII")); + BufferedReader reader = new BufferedReader(new InputStreamReader(stream, UTF_8)); StringBuilder ret = new StringBuilder(); int data; @@ -1345,7 +1347,7 @@ class CurrentJarUnpacker { public void writeTextStream(InputStream zis, File outputFile) throws IOException { BufferedWriter os = new BufferedWriter(new FileWriter(outputFile)); - BufferedReader r = new BufferedReader(new InputStreamReader(zis, "US-ASCII")); + BufferedReader r = new BufferedReader(new InputStreamReader(zis, UTF_8)); String l; while ((l = r.readLine()) != null) { @@ -1386,7 +1388,7 @@ class CurrentJarUnpacker { } // InputStream stream = url.openStream(); -// BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "US-ASCII")); +// BufferedReader reader = new BufferedReader(new InputStreamReader(stream, UTF_8)); // String line = reader.readLine(); // installPane.nBytes = Integer.parseInt(line); // @@ -1727,7 +1729,7 @@ class JarUnpacker { public void writeTextStream(ZipInputStream zis, File outputFile) throws IOException { BufferedWriter os = new BufferedWriter(new FileWriter(outputFile)); - BufferedReader r = new BufferedReader(new InputStreamReader(zis, "US-ASCII")); + BufferedReader r = new BufferedReader(new InputStreamReader(zis, UTF_8)); String l; while ((l = r.readLine()) != null) { -- 2.39.5