Skip to content

Commit 2334335

Browse files
committed
Output java files in UTF-8 and force compiler to use UTF-8
1 parent f3d7e49 commit 2334335

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

java/src/processing/mode/java/Compiler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ static public boolean compile(JavaBuild build) throws SketchException {
6868
//"-noExit", // not necessary for ecj
6969
"-source", "1.7",
7070
"-target", "1.7",
71+
"-encoding", "utf8",
7172
"-classpath", build.getClassPath(),
7273
"-nowarn", // we're not currently interested in warnings (works in ecj)
7374
"-d", build.getBinFolder().getAbsolutePath() // output the classes in the buildPath

java/src/processing/mode/java/JavaBuild.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
package processing.mode.java;
2525

2626
import java.io.*;
27+
import java.nio.charset.StandardCharsets;
28+
import java.nio.file.Files;
2729
import java.util.ArrayList;
2830
import java.util.Enumeration;
2931
import java.util.HashMap;
@@ -249,14 +251,15 @@ public String preprocess(File srcFolder,
249251
outputFolder.mkdirs();
250252
// Base.openFolder(outputFolder);
251253
final File java = new File(outputFolder, sketch.getName() + ".java");
252-
final PrintWriter stream = new PrintWriter(new FileWriter(java));
254+
BufferedWriter bw = Files.newBufferedWriter(java.toPath(), StandardCharsets.UTF_8);
255+
final PrintWriter stream = new PrintWriter(bw);
253256
try {
254257
result = preprocessor.write(stream, bigCode.toString(), codeFolderPackages);
255258
} finally {
256259
stream.close();
257260
}
258-
} catch (FileNotFoundException fnfe) {
259-
fnfe.printStackTrace();
261+
} catch (IOException e) {
262+
e.printStackTrace();
260263
String msg = "Build folder disappeared or could not be written";
261264
throw new SketchException(msg);
262265

0 commit comments

Comments
 (0)