Skip to content

Commit

Permalink
not use default encoding
Browse files Browse the repository at this point in the history
--HG--
branch : 2.x
  • Loading branch information
pxb1988 committed Sep 20, 2014
1 parent 821de1e commit 49e2dab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -26,6 +27,7 @@
import java.lang.reflect.Field;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.spi.FileSystemProvider;
Expand Down Expand Up @@ -443,7 +445,7 @@ protected void parseSetArgs(String... args) throws IllegalArgumentException, Ill
}

protected void usage() {
PrintWriter out = new PrintWriter(System.err, true);
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.err, StandardCharsets.UTF_8), true);

final int maxLength = 80;
final int maxPaLength = 40;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.*;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;

Expand Down Expand Up @@ -134,7 +132,7 @@ private void assemble1(Path file, Path output) throws IOException {
cn.version = versions[classVersion];
}
if (dump) {
new JasminDumper(new PrintWriter(System.out, true)).dump(cn);
new JasminDumper(new PrintWriter(new OutputStreamWriter(System.out, StandardCharsets.UTF_8), true)).dump(cn);
}
cn.accept(cw);
Path clzFile = output.resolve(cn.name.replace('.', '/') + ".class");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;

Expand Down Expand Up @@ -72,9 +73,9 @@ public static byte[] readDex(byte[] data) throws IOException {
if (data.length < 3) {
throw new IOException("File too small to be a dex/zip");
}
if ("dex".equals(new String(data, 0, 3))) {// dex
if ("dex".equals(new String(data, 0, 3, StandardCharsets.ISO_8859_1))) {// dex
return data;
} else if ("PK".equals(new String(data, 0, 2))) {// ZIP
} else if ("PK".equals(new String(data, 0, 2, StandardCharsets.ISO_8859_1))) {// ZIP
try (ZipFile zipFile = new ZipFile(data)) {
ZipEntry classes = zipFile.findFirstEntry("classes.dex");
if (classes != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
Expand Down Expand Up @@ -142,7 +144,7 @@ public void visitFile(Path file, Path relative) throws IOException {
+ method.desc);
if (detail) {
ex.printStackTrace(System.err);
printAnalyzerResult(method, a, new PrintWriter(System.err));
printAnalyzerResult(method, a, new PrintWriter(new OutputStreamWriter(System.err, StandardCharsets.UTF_8)));
}
}
}
Expand Down

0 comments on commit 49e2dab

Please sign in to comment.