Skip to content

Commit f8294d2

Browse files
committed
Check that Unicode works with the MYSQL format which uses backslash as its escape character
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1300591 13f79535-47bb-0310-9956-ffa450edef68
1 parent ecf59be commit f8294d2

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/test/java/org/apache/commons/csv/CSVParserTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,17 @@ public void testUnicodeEscape() throws Exception {
361361
assertFalse("Should not have any more records", iterator.hasNext());
362362
}
363363

364+
public void testUnicodeEscapeMySQL() throws Exception {
365+
String code = "abc\t\\u0070\\u0075\\u0062\\u006C\\u0069\\u0063";
366+
CSVParser parser = new CSVParser(code, CSVFormat.MYSQL.withUnicodeEscapesInterpreted(true));
367+
final Iterator<String[]> iterator = parser.iterator();
368+
String[] data = iterator.next();
369+
assertEquals(2, data.length);
370+
assertEquals("abc", data[0]);
371+
assertEquals("public", data[1]);
372+
assertFalse("Should not have any more records", iterator.hasNext());
373+
}
374+
364375
public void testCarriageReturnLineFeedEndings() throws IOException {
365376
String code = "foo\r\nbaar,\r\nhello,world\r\n,kanu";
366377
CSVParser parser = new CSVParser(new StringReader(code));

0 commit comments

Comments
 (0)