• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

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..

 
It's just a flesh wound! Or a tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic