• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error while using string.getBytes() method

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for the replies. I will post the results once i am done with that.

Thanks again..

 
I like you because you always keep good, crunchy cereal in your pantry. This tiny ad agrees:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic