File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Issue in character encoding

 
Abhishek Purwar
Ranch Hand
Posts: 63
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends.......
I am currently working on my project and got stuck with a strange problem..........

I am working on windows machine and using eclipse and tomcat for my application.........

I am reading data from xls file in my application and storing it in database(mysql).....
in my xls sheet when i give non-english characters it got read correctly by my application and stored in the same way
in the database ........

But when i worked on linux machine and using same softwares i.e. eclipse, tomcat and mysql........
my application didn't read xls file having special charaters correctly .......
means it changes it into some other characters and store it in that manner only in database.

And when i debug my appkication in windows while reading it shows workbooksetting encoding cp1252........
but in linux it shows utf-8.......

it troubles me very much........
so please let me get out of this problem.........
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whenever you perform character I/O you need to specify which encoding you want to use; if you don't, then the platform default encoding will be used. That's MacRoman on OS X, CP-1252 on Windows, and generally either UTF-8 or ISO-8859-1 on Linux. So you need to think about which encoding you want at which place, and make sure that that gets used everywhere in the code.

Also make sure that the DB is set to use Unicode (or some other encoding that can accommodate all the characters you need to store, but not ASCII).
 
Abhishek Purwar
Ranch Hand
Posts: 63
Eclipse IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Whenever you perform character I/O you need to specify which encoding you want to use; if you don't, then the platform default encoding will be used. That's MacRoman on OS X, CP-1252 on Windows, and generally either UTF-8 or ISO-8859-1 on Linux. So you need to think about which encoding you want at which place, and make sure that that gets used everywhere in the code.

Also make sure that the DB is set to use Unicode (or some other encoding that can accommodate all the characters you need to store, but not ASCII).


Thanks for your suggestion.
Can you tell me how can i do that so that it can be platform independent???
And i am able to store non-english characters in both platform correctly in the database......
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic