[Git][java-team/csvjdbc][upstream] New upstream version 1.0.35+ds

Mechtilde Stehmann gitlab at salsa.debian.org
Fri Sep 13 05:44:11 BST 2019



Mechtilde Stehmann pushed to branch upstream at Debian Java Maintainers / csvjdbc


Commits:
6f7b560d by Mechtilde at 2019-09-09T17:59:38Z
New upstream version 1.0.35+ds
- - - - -


5 changed files:

- build/build.xml
- pom.xml
- src/main/java/org/relique/jdbc/csv/CsvStatement.java
- src/test/java/org/relique/jdbc/csv/TestCsvDriver.java
- + src/testdata/utf8_bom.csv


Changes:

=====================================
build/build.xml
=====================================
@@ -36,7 +36,7 @@
   <!-- =================================================================== -->
   <property name="TALK" value="false" />
   <property name="name" value="csvjdbc"/>
-  <property name="rel" value="1.0-33"/>
+  <property name="rel" value="1.0-35"/>
   <property name="rel.name" value="${name}-${rel}"/>
   <property name="build.dir" value="../build"/>
   <property name="src.dir" value="../src"/>


=====================================
pom.xml
=====================================
@@ -3,7 +3,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>net.sourceforge.csvjdbc</groupId>
   <artifactId>csvjdbc</artifactId>
-  <version>1.0.34</version>
+  <version>1.0.35</version>
   <packaging>jar</packaging>
   <name>CsvJdbc</name>
   <description>a Java JDBC driver for reading comma-separated-value files</description>
@@ -18,7 +18,7 @@
 
   <scm>
     <connection>scm:git:ssh://git.code.sf.net/p/csvjdbc/code</connection>
-    <tag>csvjdbc-1.0.34</tag>
+    <tag>csvjdbc-1.0.35</tag>
     <url>http://sourceforge.net/p/csvjdbc/_list/git</url>
   </scm>
 


=====================================
src/main/java/org/relique/jdbc/csv/CsvStatement.java
=====================================
@@ -426,6 +426,32 @@ public class CsvStatement implements Statement
 						input = new LineNumberReader(tableReader.getReader(this, tableName));
 					}
 
+					String charset = connection.getCharset();
+					if (charset != null)
+					{
+						if (charset.equalsIgnoreCase("UTF-8"))
+						{
+							/*
+							 * Microsoft Windows programs write the Byte Order Mark
+							 * (BOM) 0xEF 0xBB 0xBF at the start of UTF-8 text files.
+							 *
+							 * Java does not support this and returns these three
+							 * bytes as first bytes in the file, so we have to skip
+							 * them manually, if they exist.
+							 */
+							input.mark(1);
+							int bom = input.read();
+							if (bom != 0xFEFF)
+							{
+								/*
+								 * First character is not a BOM,
+								 * so reset back to start of file.
+								 */
+								input.reset();
+							}
+						}
+					}
+
 					String headerline = connection.getHeaderline(tableName);
 					CsvRawReader rawReader = new CsvRawReader(input,
 						tableName,


=====================================
src/test/java/org/relique/jdbc/csv/TestCsvDriver.java
=====================================
@@ -2727,6 +2727,28 @@ public class TestCsvDriver
 		assertFalse(results.next());
 	}
 
+	@Test
+	public void testSkippingUtf8ByteOrderMark() throws SQLException, ParseException
+	{
+		Properties props = new Properties();
+		props.put("charset", "UTF-8");
+
+		/*
+		 * Check that the 3 byte Byte Order Mark at start of file is skipped.
+		 */
+		Connection conn = DriverManager.getConnection("jdbc:relique:csv:"
+				+ filePath, props);
+		Statement stmt = conn.createStatement();
+		ResultSet results = stmt.executeQuery("SELECT * FROM utf8_bom");
+
+		assertTrue(results.next());
+		ResultSetMetaData metadata = results.getMetaData();
+		assertEquals("name of column 1 is incorrect", "foo", metadata.getColumnName(1));
+		assertEquals("name of column 2 is incorrect", "bar", metadata.getColumnName(2));
+		assertEquals("Incorrect value 1", "1", results.getString(1));
+		assertEquals("Incorrect value 2", "3", results.getString(2));
+	}
+
 	@Test
 	public void testSkippingLeadingLines() throws SQLException
 	{


=====================================
src/testdata/utf8_bom.csv
=====================================
@@ -0,0 +1,3 @@
+"foo","bar","b☺z"
+1,3,5
+2,4,6



View it on GitLab: https://salsa.debian.org/java-team/csvjdbc/commit/6f7b560d4e50eb9e3c88dfa6a866a14597cb37b5

-- 
View it on GitLab: https://salsa.debian.org/java-team/csvjdbc/commit/6f7b560d4e50eb9e3c88dfa6a866a14597cb37b5
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20190913/f9ea0715/attachment.html>


More information about the pkg-java-commits mailing list