Skip to content

Commit 7b9ffbb

Browse files
authored
Merge pull request #5659 from michelou/utf8-pipe
Fix character encoding when piping stdout on Windows
2 parents caac6b9 + bde8cb4 commit 7b9ffbb

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ trait RunnerOrchestration {
117117
val sb = new StringBuilder
118118

119119
if (childStdout eq null)
120-
childStdout = new BufferedReader(new InputStreamReader(process.getInputStream))
120+
childStdout = new BufferedReader(new InputStreamReader(process.getInputStream, "UTF-8"))
121121

122122
var childOutput: String = childStdout.readLine()
123123

@@ -127,8 +127,7 @@ trait RunnerOrchestration {
127127
childOutput = childStdout.readLine()
128128

129129
while (childOutput != ChildJVMMain.MessageEnd && childOutput != null) {
130-
sb.append(childOutput)
131-
sb += '\n'
130+
sb.append(childOutput).append(System.lineSeparator)
132131
childOutput = childStdout.readLine()
133132
}
134133

@@ -161,7 +160,7 @@ trait RunnerOrchestration {
161160
val url = classOf[ChildJVMMain].getProtectionDomain.getCodeSource.getLocation
162161
val cp = Paths.get(url.toURI).toString + JFile.pathSeparator + Properties.scalaLibrary
163162
val javaBin = sys.props("java.home") + sep + "bin" + sep + "java"
164-
new ProcessBuilder(javaBin, "-Xmx1g", "-cp", cp, "dotty.tools.vulpix.ChildJVMMain")
163+
new ProcessBuilder(javaBin, "-Dfile.encoding=UTF-8", "-Xmx1g", "-cp", cp, "dotty.tools.vulpix.ChildJVMMain")
165164
.redirectErrorStream(true)
166165
.redirectInput(ProcessBuilder.Redirect.PIPE)
167166
.redirectOutput(ProcessBuilder.Redirect.PIPE)

0 commit comments

Comments
 (0)