At the time of fetching records of a column ("emp_name") in Arabic format from Oracle database table, getting question mark instead of Arabic name (??????) when I fetch records like:
String emp_name = rs.getString("EMP_NAME");
But If I changed the above line like:
String emp_name = new String(rs.getString("EMP_NAME").getBytes("UTF-8")); getting Arabic name perfectly. But in some Arabic names I found garbage characters mentioned below: "احمد عبدالحليم سي�? ابراهيم محمود"
How can I eliminate the �? (garbage character)? Is there any Unicode other than UTF-8 which supports the Arabic name perfectly or will I need to modify the above code to solve the issue?
The schema and tables all have charset and collation of Latin1, but if I try to retrieve Chinese characters from table, it only gives ?????. I don't have access to change the schema or tables properties. How can I convert the charset to actual characters in JDBC?
We have a accented Character value in DB2 table as "POKORNÝ" when i am trying to process the data through java and writing into csv file the value has been changed to "POKORNÃ". I tried converting the value to UTF-8 before writing into CSV but no luck.
DB :
CSV :
I connect to Oracle database which has NLS_CHARACTERSET (WE8ISO8859P1) , which as far as I know cannot support storing Arabic text.
But Toad for Oracle can read Arabic from this database:
However, I cannot read this using java code.
even I tried to get row of them in bytes using UTL_RAW.CAST_TO_RAW
The result was "218,227,237,225,228,199,32,199,225,218,210,237,210,161,225,222,207,32,199,211,202,229,225,223,202,32,32,56,48,37,32,227,228,32,230,205,207,199,202,32,221,225,237,223,211,32,32,32"
In a test java class, I tried to create new String(new char[]{}) using the above mentioned bytes, with no luck to display Arabic characters.
Any help ? , thank you.
This could be caused by quite a few things:
Check the column type in database it should be NVARCHAR not VARCHAR (notice the "N" at the beginning of the word)
Try to put charset=utf8 in the connection string
Convert the byte[] to string using UTF-8 encoding like this
String arabicText = new String(byteArray, "UTF-8");
I am working on inserting non-English characters in the database which is UTF-8 enabled.
I am able to insert non-English characters in the database. When I insert the URL (it passes through response of JSP and because UTF8 encoding is set, it's converted to UTF8 format)
"1"
http://heenaparekh.com/category/%E0%AA%AF%E0%AA%BE%E0%AA%A4%E0%AB%8D%E0%AA%B0%E0%AA%BE%E0%AA%AA%E0%AB%8D%E0%AA%B0%E0%AA%B5%E0%AA%BE%E0%AA%B8/
it appears correctly in database table as
"2"
http://heenaparekh.com/category/યાતરાપરવાસ
But when I am trying to select the value with same string "1" which I used for inserting in the database (without passing through request and response of JSP) :
When the select statement is run with the link as same URL "1", it is converted to URL "2" by request of JSP.
When I want to select the rows with this URL, I am not able to extract as I am not able to convert URL "1" to URL "2" in my JSP application and I don't need to shift to different page so I have tried the following methods to convert it into URL "2" format:
I have tried converting my string to UTF-8 format but it's not helping. String is printed to be same. When I convert it using Entities class of Nutch to UTF8 format then also it is not fetching results, maybe as UTF8 conversion by response of JSP and Entities class are different.
Please help me how to bring both the URLs to same format so that I can extract it from the database.
You need to URL-unencode rather than "UTF-unencode" the string. Internally, Java stores strings as UTF-16, but that doesn't matter for your purposes. Try the java.net.URLDecoder.decode(String, String) method.