Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Search texting that includes special characters, e.g. ã, é or í

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is there a search method that can match special characters with their standard counterpart?

For example:
I'd like a search for "Sao" to find a match in "São Tomé and Príncipe" etc.

I don't really know where to start, I could store the country name twice, once as regular and once including special characters, but then I'd have to search both...

I'm hoping someone has a better idea.

 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider java.text.RuleBasedCollator class.

Here is a code to compare strings with polish characters and their counterparts (ą=a, ł=l etc.):


Of course code says that these two strings are identical
I didnt test this class in practice, probably performance could be the problem.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!