What you need here is this:
String finalstr = new String(rs.getString("subject").getBytes(),"Cp1256");
What your code does is:
String finalstr = rs.getString("subject");
user13109986 wrote:There could be. What does the documentation for the JDBC driver say? You might have to specify the charset in the JDBC URL, or something like that. (Even though all the driver has to do is to translate from the database's charset to Unicode.)
Is there any conversion happening at JDBC api level?
Is there anything wrong with my environment?Locales have nothing to do with it.
I also changed my machine locale to Arabic and in the java also the locale is set to ar_AE.
user13109986 wrote:That's exactly what it's supposed to do. There isn't even any concept of what it would mean to disable that: Java characters are UTF-16 representations of Unicode code-points, so there isn't anything else it could do.
My understanding is the JDBC Api converts the string from the database to UTF-16.. If so is there any way to disable the UTF-16 encoding at JDBC API?
Windows-1256 is a code page used to write Arabic (and possibly some other languages that use Arabic script, like Persian) under Microsoft Windows. This code page is not compatible with ISO 8859-6 and MacArabic encodings.So was there a particular reason you chose Cp1256 and not ISO-8859-6 as the charset to write to the file with?
user13109986 wrote:Don't try any encodings. In fact don't use writing to a file and reading with some secret tool as a testing method at all. Write some code which reads data which you suspect to be a problem, then break the string down into its component characters and output their Unicode values (which are integers). Don't use getBytes() at all in this process either.
I tried Windows-1256 and ISO-8859-6, all gives same result.