From f8294d2d225600e29720c7a1c5c33cda00591bf6 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Wed, 14 Mar 2012 15:26:14 +0000 Subject: [PATCH] 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 --- .../java/org/apache/commons/csv/CSVParserTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/org/apache/commons/csv/CSVParserTest.java b/src/test/java/org/apache/commons/csv/CSVParserTest.java index 475b961c..fb53af49 100644 --- a/src/test/java/org/apache/commons/csv/CSVParserTest.java +++ b/src/test/java/org/apache/commons/csv/CSVParserTest.java @@ -361,6 +361,17 @@ public class CSVParserTest extends TestCase { assertFalse("Should not have any more records", iterator.hasNext()); } + public void testUnicodeEscapeMySQL() throws Exception { + String code = "abc\t\\u0070\\u0075\\u0062\\u006C\\u0069\\u0063"; + CSVParser parser = new CSVParser(code, CSVFormat.MYSQL.withUnicodeEscapesInterpreted(true)); + final Iterator iterator = parser.iterator(); + String[] data = iterator.next(); + assertEquals(2, data.length); + assertEquals("abc", data[0]); + assertEquals("public", data[1]); + assertFalse("Should not have any more records", iterator.hasNext()); + } + public void testCarriageReturnLineFeedEndings() throws IOException { String code = "foo\r\nbaar,\r\nhello,world\r\n,kanu"; CSVParser parser = new CSVParser(new StringReader(code));