> hi all,
>I have String in UTF8 format
>how can display it in ascii format.
>
No you don't. If it's in UTF-8 it's bytes, not characters. What you might have is the kind of mess you get loading a string from a file with the wrong encoding. If so then change the way you read the data rather than trying to fix it once loaded.
In general, if you're specifying an specific encoding, use InputStreamReader, wrapped arround a FileInputStream if necessary.
> hi all,
>I have String in UTF8 format
>how can display it in ascii format.
>
If the String contains only ASCII characters , then UTF-8 bytes and ASCII bytes are the same.
If the String does not contain only ASCII characters, then you cannot "display it in ascii format".
Hi friends,
Thanks for your replies,
well still my doubt is not clear,
I am doing same thing, this guy in following link is doing,
http://www-304.ibm.com/jct09002c/isv/tech/faq/individual.jsp?oid=1:78875
and as per their discussion I need to convert string format,
kindly help me
JAmol
Sounds like the Directory Server is returning a faulty string. You get this with some databases too. The may have taken a UTF-8 byte stream and converted it as if it were ISO-Latin-1.
In these cases:
1) Complain.
2) You can rescue the characters as;
String fixedString = new String(duffString.getBytes("ISO-8859-1"), "UTF-8");
This converts the data back to a byte array and then decodes it correctly.