OiO.lk Blog java Why the oracle database changes the non latin character encoding?
java

Why the oracle database changes the non latin character encoding?


I am using Oracle database with AR8MSWIN1256, and unfortunately I cannot change the encoding to UTF8.

Then I have defined a table with a column type of varchar2
and tried to run sql operations from a Java application.

Based on the character set of windows-1256 it is possible to save characters like ی, that has encoding code EC and its table is mentioned in windows-1256 encoding table. But after the saving when I fetch the data it changes to ي that has encoding code ED. This happens only for a few characters, not all of them.

I have set NLS_LANG=AMERICAN_AMERICA.AL32UTF8 environment variable on client system. The only solution that I found to fix the problem is to change the column type to nvarchar2 to change the column encoding to Unicode and setting the VM options is mentioned in the Persian character encoding in oracle database as follows:

-Doracle.jdbc.defaultNChar=true 
-Doracle.jdbc.convertNcharLiterals=true

But I do not understand why I cannot save this character correctly in windows-1256. Also, I am confused why the client application must set the defaultNChar=true.



You need to sign in to view this answers

Exit mobile version