Skip to content

Commit ca8777c

Browse files
committed
fixed wrong output when using unicode characters
1 parent 37ec49c commit ca8777c

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Include the following dependency on your pom file:
99
<dependency>
1010
<groupId>org.dropproject</groupId>
1111
<artifactId>stdin-stdout-junit-helper</artifactId>
12-
<version>0.4.0</version>
12+
<version>0.4.1</version>
1313
</dependency>
1414

1515
## How to use

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.dropproject</groupId>
88
<artifactId>stdin-stdout-junit-helper</artifactId>
9-
<version>0.4.0</version>
9+
<version>0.4.1</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Stdin/Stdout Helper for JUnit</name>

src/main/java/org/dropproject/stdinstdoutjunithelper/StdinStdoutHelper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.io.IOException;
2727
import java.io.InputStream;
2828
import java.io.PrintStream;
29+
import java.nio.charset.StandardCharsets;
2930
import java.util.ArrayList;
3031
import java.util.Arrays;
3132
import java.util.List;
@@ -393,8 +394,9 @@ protected void finalize() throws Throwable {
393394
private static String getLine(byte[] buffer, int offset, int length) {
394395

395396
String result = "";
396-
for (int i = offset; i < length; i++) {
397-
char ch = (char) buffer[i];
397+
String decodedString = new String(buffer, offset, length, StandardCharsets.UTF_8);
398+
for (int i = 0; i < decodedString.length(); i++) {
399+
char ch = decodedString.charAt(i);
398400
if (ch != '\n') {
399401
result += ch;
400402
} else {

0 commit comments

Comments
 (0)