This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error while using string.getBytes() method

 
Shruthi Sam
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 377
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
R van Vliet
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for the replies. I will post the results once i am done with that.

Thanks again..

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic