• Post Reply Bookmark Topic Watch Topic
  • New Topic

Handling Diacriticals in JAVa  RSS feed

 
ragini venkataraman
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need help with removing diacriticals in a string in Java.

In javascript u can use the unescape('%F8') to unescape the character and then do a replace by to replace it with some other character..
for ex:
text = replace(text,unescape('%C0'),'A');

how to implement this in Java??
I looked and did not find any already existing method or java class to do unescape.....someone please help
 
Jaime M. Tovar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String has a replaceall method, you can pass a regexp to replace uncommon chars.
 
ragini venkataraman
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks but i am not able to understand how to write a regex for a diacritical....
say i have something like this(`a a grave and c circonflex) in a string then how to construct a regex to remove it?? can annyone give me an example to understand this....


thanks,
ragini
 
Jaime M. Tovar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class Untitled1 {
public static void main(String [] args) {
System.out.println("aAzZ09��d-_�".replaceAll("[^\u0061-\u007A\u0020-\u003F]",""));
}
}

Hope it helps
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!