Forums Register Login

Issue with special characters

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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 ú!
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
And what happened when you tried the JOptionPane?
What is the encoding you have set on your database?
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
You have not provided much information about how it is stored in the DB.
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 942 times.
Similar Threads
Converting special characters to hex code
cannot call getoutputstream( ) after getwriter( )
Shouldn't I get 2 outputs instead of 3?
Apache POI - Column having non-english characters e.g. Thai and cell empty, then skips the cell
POI - how to accommodate multiple occurences of "Memorial" days?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:55:49.