• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Parsing a string with a e(circumflex) character

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
reply
    Bookmark Topic Watch Topic
  • New Topic