-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix possible encoding problems with wide chars if written separately
- Loading branch information
Showing
2 changed files
with
95 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
terminal/src/test/java/org/jline/utils/WriterOutputStreamTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2002-2017, the original author or authors. | ||
* | ||
* This software is distributable under the BSD license. See the terms of the | ||
* BSD license in the documentation provided with this software. | ||
* | ||
* http://www.opensource.org/licenses/bsd-license.php | ||
*/ | ||
package org.jline.utils; | ||
|
||
import org.junit.Test; | ||
|
||
import java.io.StringWriter; | ||
import java.nio.charset.Charset; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class WriterOutputStreamTest { | ||
|
||
@Test | ||
public void testWideChar() throws Exception { | ||
StringWriter sw = new StringWriter(); | ||
WriterOutputStream wos = new WriterOutputStream(sw, Charset.forName("UTF-8")); | ||
byte[] bytes = "㐀".getBytes("UTF-8"); | ||
for (byte b : bytes) { | ||
wos.write(b); | ||
} | ||
wos.flush(); | ||
assertEquals("㐀", sw.toString()); | ||
} | ||
} |