how to parse characters non ascii in a string

i am stucked in this crictical problem and i don't know how to cater this. I sometimes receive this String ⒗⒕►☻☺ and sometimes  these are non US-ASCII characters. These ⒗⒕►☻☺ characters are replaced by ? and  is represented as it is. I sometime receive this character  too. These characters are in ANSI list but i want to receive only US-ASCII. Please help me out that how to identify these characters in the string.

[463 byte] By [GameOvera] at [2007-11-26 17:28:46]
# 1

I don't understand your question.

Do you want to replace those characters with '?' s or are those characters getting replaced with '?' s

Where is this coming from? (Are you reading a file, a gui, etc.)

Please post a simple example of your problem so we can run it and see whatever you see (don't post all your code, just like a 20 line working example).

zadoka at 2007-7-8 23:56:43 > top of Java-index,Core,Core APIs...
# 2

Basically i am getting that string from the user in an sms. The text of the sms is saved in the database.I get that sms from database in string form. now i want to parse the string to identify the non us-ascii characters in the string. This parsing is important because when i try to post data on the url i get the http response code 400 which creates an exception and i get stucked in an infinite while loop.

HttpURLConnection urlcon =null;

String postingdata="&message="+ URLEncoder.encode(ob.getmessage(),"UTF-8")

System.out.println(postingdata);

URL url = new URL("http://someurl");

urlcon = (HttpURLConnection)url.openConnection();

urlcon.setDoOutput(true);

urlcon.setRequestMethod("POST");

OutputStreamWriter wr = new OutputStreamWrite(urlcon.getOutputStream());

wr.write(postingdata);

wr.flush();

BufferedReader rd = new BufferedReader(new InputStreamReader(urlcon.getInputStream()));

rd.close();

wr.close();

GameOvera at 2007-7-8 23:56:43 > top of Java-index,Core,Core APIs...
# 3
I was trying to help you, but then I noticed you are cross posting. Please stop it.
zadoka at 2007-7-8 23:56:43 > top of Java-index,Core,Core APIs...
# 4
i am sorry for that i have posted this somewhere else too but i wasn't getting any response so i posted it here and haven't posted it anywhere else. and i will communicate it only here and nowhere else
GameOvera at 2007-7-8 23:56:43 > top of Java-index,Core,Core APIs...
# 5

> i am sorry for that i have posted this somewhere else

> too but i wasn't getting any response so i posted it

> here and haven't posted it anywhere else. and i will

> communicate it only here and nowhere else

The problem with crossposting, is that multiple people will answer your one question. Which wastes everyones times.

Did you read Saish's reply on your other thread? Did it solve your problem?

Anyway, you waited 1.5 hours before reposting.That is not long at all. Second if you do not get an answer and thing you might have it in the wrong forum, post a link back to your original question so that all the discussion can take place on the same topic.

zadoka at 2007-7-8 23:56:43 > top of Java-index,Core,Core APIs...
# 6

They are undoubtedly hex. Download a hex editor and view the values to see if they make sense. If you simply want to strip out the alphanumeric characters, write a simple RegEx expression.

These characters were catered by the code below ⒗⒕►☻☺

//String test = "";

String test = "⒗⒕►☻☺";

byte bytearray [] = test.getBytes("US-ASCII");

System.out.println("Test string : " + test);

CharsetDecoder d = Charset.forName("ASCII").newDecoder();

try

{

System.out.println("inside try");

CharBuffer r = d.decode(ByteBuffer.wrap(bytearray));

r.toString();

}

catch(CharacterCodingException e) {

System.out.println("only regular ASCII characters please!");

// interrupt the processing

//throw new Exception(e);

}

But i am unable to cater this character  which is named as unused in ANSI standard

GameOvera at 2007-7-8 23:56:43 > top of Java-index,Core,Core APIs...
# 7
no response yet :(
GameOvera at 2007-7-8 23:56:43 > top of Java-index,Core,Core APIs...
# 8
> Download a hex editor and view the values to see if they make sense. It's still good advice. Why don't you take it?What hex value is the  character, and is that in the range 0-127?
ejpa at 2007-7-8 23:56:43 > top of Java-index,Core,Core APIs...
# 9
no it is not in the range its value is 129
GameOvera at 2007-7-8 23:56:43 > top of Java-index,Core,Core APIs...
# 10
That's curious. I make it 0x5, using Integer.toHexString("".charAt(0));. How did you get 129?
ejpa at 2007-7-8 23:56:43 > top of Java-index,Core,Core APIs...