File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Issue with special characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Issue with special characters" Watch "Issue with special characters" New topic
Author

Issue with special characters

Thanuja Vishwanath
Ranch Hand

Joined: Oct 07, 2010
Posts: 49
Hi,
iam creating a java class to read values from excel and insert into DB. Iam using POI package. In excel i have one column which has values like this ≤ 7⅜ x 9¼“ or 260 x 195mm. After reading the values from the cell using POI it is inserted into database as ? 7? x 9?? or 260 x 195mm. First i thought that it is something to do with POI package and was searching for a solution. But after searching i found that it is not issue with POI. It is something to do with java. To confirm this i just assigned the value to a string (hardcoded) and when i did system.out.println it gives output as below. Special characters are replaced by ?.



but the output is: ? 7? x 9?? or 260 x 195mm

What should i do for this?

Thanks.

Thanks,
Thanuja.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39791
    
  28
Start by trying the display on a Java component: JOptionPane.showMessagedialog(null, "value:"+printVal);
The Windows® terminal is notorious for displaying only a restricted range of characters. I hve had command lines where £ appeared as ú!
Thanuja Vishwanath
Ranch Hand

Joined: Oct 07, 2010
Posts: 49
Campbell Ritchie wrote:Start by trying the display on a Java component: JOptionPane.showMessagedialog(null, "value:"+printVal);
The Windows® terminal is notorious for displaying only a restricted range of characters. I hve had command lines where £ appeared as ú!


Even in mysql database it is getting inserted like this. Only because of this i added print statement to check.

Thanks.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39791
    
  28
And what happened when you tried the JOptionPane?
What is the encoding you have set on your database?
Thanuja Vishwanath
Ranch Hand

Joined: Oct 07, 2010
Posts: 49
Campbell Ritchie wrote:And what happened when you tried the JOptionPane?
What is the encoding you have set on your database?


Campbell as you said it is printing properly in JOptionPane. I checked my database encoding which was latin. I changed it to utf8 and also changed the table properties to utf8. Again i executed my program and it inserts with question mark in the db. But when i tried to store directly in table using insert query it is properly inserted. From this i feel i fixed the db issue by changing latin to utf8. I guess problem is the value passed from java. iam bit confused with this and not sure why it is printing in jOptionPane properly but not getting inserted in db properly.

Please advise should i do anything else in java part?

Thanks.
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 875
    
    5
You have not provided much information about how it is stored in the DB.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Issue with special characters