• Post Reply Bookmark Topic Watch Topic
  • New Topic

converting String from UTF 8 to ascii format  RSS feed

 
Amol Juvatkar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
I have String in UTF8 format,
how can display it in ascii format.

Thanks,
JAmol
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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.
 
Paul Clapham
Sheriff
Posts: 22712
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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.
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • 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
  • 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: 22712
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you are getting a byte array from JNDI. You convert it to a String like this:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!