I have a Java stored procedure which fetches record from the table using Resultset
object and creates a CS Vfile.
BLOB retBLOB = BLOB.createTemporary(conn, true, BLOB.DURATION_SESSION);
retBLOB.open(BLOB.MODE_READWRITE);
OutputStream bOut = retBLOB.setBinaryStream(0L);
ZipOutputStream zipOut = new ZipOutputStream(bOut);
PrintStream out = new PrintStream(zipOut,false,"UTF-8");
out.write('\ufeff');
out.flush();
zipOut.putNextEntry(new ZipEntry("filename.csv"));
while (rs.next()){
out.print("\"" + rs.getString(i) + "\"");
out.print(",");
}
out.flush();
zipOut.closeEntry();
zipOut.close();
retBLOB.close();
return retBLOB;
But the generated CSV file doesn't show the correct German character. Oracle database also has a NLS_CHARACTERSET
value of UTF8.
Please suggest.
@encoding UTF-8
in Java files. I understand that this only works for supersets of ASCII like UTF-8, ISO 8859-?, MacRoman, or CP1252, and that it has to occur before any non-ASCII characters are seen. But this is the same restriction as in-band encoding specs in XML, Perl, and Python. I’m told it wouldn’t be not too hard to implement an annotator like that, but apart from regexes and encodings, my Java-fu is weak. Sure would be useful, eh?! – Catiline