Reputation: 4478
I have two programs- First one being a C program that writes in to mysql database. Second is a java program that reads the data from mysql database. The C program reads list of files in a particular directory and inserts the file names in DB. The Java program reads these rows and tries to do some file processing using these file names.
A particular file name contains a long dash '–' character. This fileName is read from DB by the java program. But when it tries to open the File on filesystem for this entry, the file names won't match.
When I read the file name (containing the '–' character) directly from file system using Java, the bytes for '–' character is shown as [-30 -128 -109]. Whereas the bytes shown when Java reads the fileName from DB (fileName dumped by C program), the bytes for '–' character is shown as [-61 -94 -30 -126 -84 -30 -128 -100] in Java.
Is this something to do with the Charset used by C program to put entried in to mysql?
Please help..
Thanks,
-Keshav
Upvotes: 0
Views: 148
Reputation: 63538
Java strings consist of Unicode characters, not bytes. So the problem may be that either
How did you enter the strings into the database? What is your table definition? What connection encoding are you using on the client applications?
Normally it's best for your sanity to use utf8 for everything (Table definition & connection encoding). If you're not doing this, you'll probably end up breaking things in some way.
Upvotes: 2