10-14-2013 12:10 PM
i have some text file which contain some special chatacters appers like encoded characters, i want to replace them but they are not replacing, i am able to replace all others characters except that special encoded characters,
how can i replace them.
below is that special character..
actualText.replace(' ’ ', ' ' ');
please help me..
10-14-2013 12:32 PM
Sorry don't understand this question.
What character can you not replace? Can you give us the Unicode number associated with it?
Can you not say something like
char oldChar = '/u...';
char newChar = '/...';
I suspect in fact there is an underlying problem here, in that you have obtained some data from the Server and are struggling to process it. Remember it is probably UTF-8 encoded, and that if you are using XML, the values will have been converted so that they can be placed in a XML string. Replacing characters will probably not help in these cases.
10-14-2013 12:51 PM
i have already highlighted that special character in the replace function parameter my old char parameter contain that character , acutally i have copied some text from the internet which appear like a '(comma) but when we display that inside the label field its looks like a rectangle box...
on my new hubby’s birthday
here ’s the character...
10-14-2013 01:07 PM - edited 10-15-2013 04:59 AM
Add code to convert the String to a char array, debug your application, view the String in the debugger and tell us what the character actually is. Possibly a character array will enable you to see the actual character better.
String testString = "test stiing2";
char  testChars = testString.toCharArray();
Now look at the testChars array, find the characters that is causing the problem, and tell us what it is.
You said you copied it from the internet, how did you do get the data? More specifically, how do you convert the bytes you get from the internet to a String for display? What encoding do you use in your conversion?
10-14-2013 01:26 PM
To find out exactly what the character is, you might have to change the Primitive display. In Debug perspective, look for the Variables window, and use the mneu form there to get the Java Preferences:
Change primiative Display to display hexadecimal values.
See attached screen shots.
Note that the characters are also displayed with the /u form.
10-15-2013 02:31 AM
actually i copied data from the internet and store it into the text file ,
and i am reading that text file using InputStream and than converting that data into string...
10-15-2013 05:03 AM
"actually i copied data from the internet and store it into the text file ,
and i am reading that text file using InputStream and than converting that data into string..."
This means you have more opportunities to incorrectly process the character encoding.
I have updated my previous post to make it clearer. So can you please follow these instructions to debug the data so that we and you can figure out what the character actually is.
Can you also tell us the character encoding used by the data you have downloaded from the internet? All character data sent as bytes has an encoding, whether deliberate or not, so if you don't know it, this is something you need to find out.