Foreign language chars as map keys

James McMahon <[email protected]>
Newsgroups gmane.comp.lang.groovy.user
Message-ID <CAEqJCe0vbzfHwN9MmHU7FwrDLEL57usgJ03vmNJcmhWr2wXmMw@mail.gmail.com>
I have a Groovy list that holds the unicode representation of select
foreign language characters, something like this simplified version:

def myList = ['*\u00E4*','\u00D6','\u00F8']

I have built myself a Groovy map that is the crosstabulation of characters
by count in an incoming document, so my map looks something like this:

crossTab = ["a" : "16736", "b" : "192", " * ä  *" : "18"]

The foreign language characters in this map that are in the set of keys
often have extra whitespace around them, and for certain languages there is
a weird "right to left" thing going on that I don't quite fully understand.

My objective: iterate through my list, return true if the element from the
list is found as a key in the map, and return the count - the map value for
that key - if the key is found. My problem: my lookup is failing to return
any hits right now. I know that some of these foreign language characters
are in my data. I suspect my lookup is failing because the keys are not
clean representations of the foreign language characters.

How do I modify my keys using Groovy to trim them of leading and trailing
whitespace?

Since my element from my list is expressed as unicode, how would I convert
the trimmed key representation to unicode using Groovy?

Thank you in advance for any help.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.