aspose file tools*
The moose likes Java in General and the fly likes error while using string.getBytes() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "error while using string.getBytes() method " Watch "error while using string.getBytes() method " New topic
Author

error while using string.getBytes() method

Shruthi Sam
Ranch Hand

Joined: Jul 09, 2008
Posts: 73
Hi,
I have tried to encode using the getBytes() method. When i use some character like "€" in the string. it is not getting decoded properly. Kindly help. Please find the below code for details.




When I run the program am getting output like "ab?c%?" instead of "ab?c%€".

Please help me to get the actual value.
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

This is likely to do with your JVM's default Charset.

This link: http://www.rgagnon.com/javadetails/java-0505.html gives you instructions on how to find the charset that is being used.

Post the results.

Sean


I love this place!
R van Vliet
Ranch Hand

Joined: Nov 10, 2007
Posts: 144
Sean Clark wrote:Hey,

This is likely to do with your JVM's default Charset.

This link: http://www.rgagnon.com/javadetails/java-0505.html gives you instructions on how to find the charset that is being used.

Post the results.

Sean


Correct, this'd work for example :


The 8859_1 character set is the simple ANSI set which does not include a character for the euro symbol. As such there is no way to represent the character using this (the default) character set. Your only solution is to use a character set capable of representing this character or do some sort of custom encoding/decoding.
Shruthi Sam
Ranch Hand

Joined: Jul 09, 2008
Posts: 73
Hi,
Thanks for the replies. I will post the results once i am done with that.

Thanks again..

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error while using string.getBytes() method