Skip to content

Commit 49e2dab

Browse files
committed
not use default encoding
--HG-- branch : 2.x
1 parent 821de1e commit 49e2dab

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

d2j-base-cmd/src/main/java/com/googlecode/dex2jar/tools/BaseCmd.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.io.File;
2020
import java.io.IOException;
21+
import java.io.OutputStreamWriter;
2122
import java.io.PrintWriter;
2223
import java.lang.annotation.ElementType;
2324
import java.lang.annotation.Retention;
@@ -26,6 +27,7 @@
2627
import java.lang.reflect.Field;
2728
import java.net.URI;
2829
import java.net.URISyntaxException;
30+
import java.nio.charset.StandardCharsets;
2931
import java.nio.file.*;
3032
import java.nio.file.attribute.BasicFileAttributes;
3133
import java.nio.file.spi.FileSystemProvider;
@@ -443,7 +445,7 @@ protected void parseSetArgs(String... args) throws IllegalArgumentException, Ill
443445
}
444446

445447
protected void usage() {
446-
PrintWriter out = new PrintWriter(System.err, true);
448+
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.err, StandardCharsets.UTF_8), true);
447449

448450
final int maxLength = 80;
449451
final int maxPaLength = 40;

d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/Jasmin2JarCmd.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@
2525
import org.objectweb.asm.Opcodes;
2626
import org.objectweb.asm.tree.ClassNode;
2727

28-
import java.io.BufferedReader;
29-
import java.io.File;
30-
import java.io.IOException;
31-
import java.io.PrintWriter;
28+
import java.io.*;
3229
import java.net.URISyntaxException;
3330
import java.nio.charset.Charset;
31+
import java.nio.charset.StandardCharsets;
3432
import java.nio.file.*;
3533
import java.nio.file.attribute.BasicFileAttributes;
3634

@@ -134,7 +132,7 @@ private void assemble1(Path file, Path output) throws IOException {
134132
cn.version = versions[classVersion];
135133
}
136134
if (dump) {
137-
new JasminDumper(new PrintWriter(System.out, true)).dump(cn);
135+
new JasminDumper(new PrintWriter(new OutputStreamWriter(System.out, StandardCharsets.UTF_8), true)).dump(cn);
138136
}
139137
cn.accept(cw);
140138
Path clzFile = output.resolve(cn.name.replace('.', '/') + ".class");

dex-reader/src/main/java/com/googlecode/d2j/reader/zip/ZipUtil.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.io.File;
2424
import java.io.IOException;
2525
import java.io.InputStream;
26+
import java.nio.charset.StandardCharsets;
2627
import java.nio.file.Files;
2728
import java.nio.file.Path;
2829

@@ -72,9 +73,9 @@ public static byte[] readDex(byte[] data) throws IOException {
7273
if (data.length < 3) {
7374
throw new IOException("File too small to be a dex/zip");
7475
}
75-
if ("dex".equals(new String(data, 0, 3))) {// dex
76+
if ("dex".equals(new String(data, 0, 3, StandardCharsets.ISO_8859_1))) {// dex
7677
return data;
77-
} else if ("PK".equals(new String(data, 0, 2))) {// ZIP
78+
} else if ("PK".equals(new String(data, 0, 2, StandardCharsets.ISO_8859_1))) {// ZIP
7879
try (ZipFile zipFile = new ZipFile(data)) {
7980
ZipEntry classes = zipFile.findFirstEntry("classes.dex");
8081
if (classes != null) {

dex-tools/src/main/java/com/googlecode/dex2jar/tools/AsmVerify.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818

1919
import java.io.File;
2020
import java.io.IOException;
21+
import java.io.OutputStreamWriter;
2122
import java.io.PrintWriter;
2223
import java.lang.reflect.Field;
24+
import java.nio.charset.StandardCharsets;
2325
import java.nio.file.Files;
2426
import java.nio.file.Path;
2527
import java.util.ArrayList;
@@ -142,7 +144,7 @@ public void visitFile(Path file, Path relative) throws IOException {
142144
+ method.desc);
143145
if (detail) {
144146
ex.printStackTrace(System.err);
145-
printAnalyzerResult(method, a, new PrintWriter(System.err));
147+
printAnalyzerResult(method, a, new PrintWriter(new OutputStreamWriter(System.err, StandardCharsets.UTF_8)));
146148
}
147149
}
148150
}

0 commit comments

Comments
 (0)