• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

converting String from UTF 8 to ascii format

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
I have String in UTF8 format,
how can display it in ascii format.

Thanks,
JAmol
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ASCII text and UTF-8 will look exactly the same (ASCII characters are stored using the one byte in UTF-8) regardless of which encoding they use.
 
Sheriff
Posts: 27451
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't have a String in UTF-8 format. It's possible that you have an array of bytes that represents a String encoded using UTF-8, but Strings are raw Unicode characters and do not have an encoding. Was there another question that caused you to ask that? Perhaps it would be easier to answer the real question.
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this link might help you:

e186. Converting Between Strings (Unicode) and Other Character Set Encodings

Althoug your conversion sound a bit strange, because US-ASCII is a subset of UTF-8, hence, some of the characters that you will convert from UTF-8 to US-ASCII may not have any representation in US-ASCII, and the ones which does were already part of the UTF-8.

Well, whatever, I hope this link helps.

Regards,
Edwin Dalorzo.
 
Amol Juvatkar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Clapham:
Perhaps it would be easier to answer the real question.


hi,

real problem is ,
as per my requirement, I was trying to retrive user data, including password from LDAP using java APIs.
but password for known user is displayed in different format,
after going through link

http://www-304.ibm.com/jct09002c/isv/tech/faq/individual.jsp?oid=1:78875

it says userPassword attribute is returned in UTF-8 format. To use this attribute, you need to convert it from UTF-8 into ASCII.

hope you got my problem,

Thanks
JAmol
 
Paul Clapham
Sheriff
Posts: 27451
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you are getting a byte array from JNDI. You convert it to a String like this:
 
What's a year in metric? Do you know this metric stuff tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic