GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Parsing a string with a e(circumflex) character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Parsing a string with a e(circumflex) character" Watch "Parsing a string with a e(circumflex) character" New topic
Author

Parsing a string with a e(circumflex) character

charu latha
Ranch Hand

Joined: Aug 20, 2002
Posts: 67
I have a string which has an e with a circumflex. I need to be able to parse this string and replace this e with a circumflex with some other characters/strings

I wanted to use the replaceAll function with Strings so that i need not do an explicit parsing for each of these characters. However i am not sure how i can read this special character from my string.

Here is what i tried

charu latha
Ranch Hand

Joined: Aug 20, 2002
Posts: 67
Sorry my second string should have been "&234;" However that got replaed in the website. If only i knew how to read this character......
charu latha
Ranch Hand

Joined: Aug 20, 2002
Posts: 67
ok here is my string JOS� LEAL. The e is what i have to replace. I know how to replace it ie., use the replaceAll of the String method. However i dont know how to actually recognize this character in my Java code.
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
Ok Here's how I went about doing this..

I am keeping my source file in ASCII.
Using a windows 2000 box I open up the character map application.
I change the font to Arial Unicode MS.
I look for the character �, click on it to find the
unicode code point on the status bar of the window.
It tells me that it is U+00C9.

Then open up notepad,
change the font to Arial Unicode MS (at least from windows 2000 onwards Notepad supports Unicode)
I use a key value pair and put the value as JOS� LEAL.
I use the java.util.Properties class to read it in to
a String variable called strToReplace in my java program.
(I am doing this because my source is in ASCII)

Then I do..

finaler = strToReplace.replaceAll("\u00C9","X");
System.out.println(finaler);

Output:
JOSX LEAL

However there may be some gotcha's here which I haven't understood yet.

[ September 11, 2008: Message edited by: Gamini Sirisena ]
[ September 11, 2008: Message edited by: Gamini Sirisena ]
 
GeeCON Prague 2014
 
subject: Parsing a string with a e(circumflex) character