Permalink
Browse files

Fix corrupt string that contain non-ASCII characters

  • Loading branch information...
1 parent 6dbf0ba commit 5f59b3750287e73973ab0b902df21a20f728e16b @takai committed Apr 17, 2012
@@ -72,7 +72,8 @@ public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) {
public static String colorize(String data) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
AnsiColorizer colorizer = new AnsiColorizer(out, Charset.defaultCharset());
- colorizer.eol(data.getBytes(), data.length());
+ byte[] bytes = data.getBytes();
+ colorizer.eol(bytes, bytes.length);
return out.toString();
}
@@ -84,6 +84,11 @@ public void testEscapeHtml() throws IOException {
assertThat(colorize(">"), is(">"));
}
+ @Test
+ public void testUTF8Character() throws IOException {
+ assertThat(colorize("\u3053\u3093\u306b\u3061\u306f"), is("<b>\u3053\u3093\u306b\u3061\u306f</b>"));
+ }
+
private String colorize(String text) throws IOException {
return AnsiColorNote.colorize(text);
}

0 comments on commit 5f59b37

Please sign in to comment.