File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How do I handle string match with these Puerto Rico cities (spanish) ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How do I handle string match with these Puerto Rico cities (spanish) ?" Watch "How do I handle string match with these Puerto Rico cities (spanish) ?" New topic
Author

How do I handle string match with these Puerto Rico cities (spanish) ?

Steve Mutanson
Ranch Hand

Joined: Apr 15, 2003
Posts: 67
There are couple area in Puerto Rico --- Mayaguez (where the character 'u' is spanish so it has two dots on top), and San Juan-Bayamon (the character 'o' is in spanish so there is a dash on top of it). The database in in English version so it translated into 'u' and 'o' respectively.
Now, after retrieving the data from database I need to match with some file in which the characters are stored as Spanish (just for these TWO names they keep the spanish version, actually just for these TWO characters). So the comparison fails. How do I make it work ?
thanks,
steve
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Well I haven't done this myself, nor even read all of the tutorial on this - but I believe that you want the Collator class for a flexible approach to lexical comparisons.
Alternately you might write some sort of custom converter that replaces any ü with u, etc. just before performing other comparisons. But I tend to thing the Collator is the "right" way to approach this.


"I'm not back." - Bill Harding, Twister
Steve Mutanson
Ranch Hand

Joined: Apr 15, 2003
Posts: 67
actually let's discuss a much much simpler question -- Suppose I want to create a hashmap and use the English word as key and Spanish/French as value. Then I can easily grab them. The confusing thing is -- How do I store that Spanish or French value in the hashtable since I can't type them in ??
Richard Jensen
Ranch Hand

Joined: May 14, 2003
Posts: 67
Originally posted by Steve Mutanson:
How do I store that Spanish or French value in the hashtable since I can't type them in ??

Use the appropriate unicode values. These are converted automatically for you since Java uses 16-bit chars.

(I'm not sure if I got the exact characters you mentioned in your first post, but you get the idea).


Richard
N 37 33 W 122 18
Steve Mutanson
Ranch Hand

Joined: Apr 15, 2003
Posts: 67
Originally posted by Richard Jensen:

(I'm not sure if I got the exact characters you mentioned in your first post, but you get the idea).

From
http://gsu.linux.org.tr/oreilly/Java%20Enterprise/servlet/appd_01.htm
I found what I want is "\u00fc" and "\u00f3". However, when I simply do the System.out.println("\u00f3" + ", \u00fc"); it does not look like what I want. For example, \u00fc represents the "u" with 2 dots on the top, but it shows a little "n" on the top and nothing on the bottom. Have you tried any example yourself ?
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
You have to realize that odd characters aren't going to print correctly when you send them to the console. Write them in a JOptionPane and make sure you have the right fonts installed to see what they look like.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Steve Mutanson
Ranch Hand

Joined: Apr 15, 2003
Posts: 67
Folks,
thanks for input. Now, when taking and outputing such strings, my X-term window works as follows -- For the known characters it output as it is, for those unknown char, it just outputs "?". this prevents me from knowing what it is and what unicode I should use to replace it. Thus, I want to know --- Instead of outputing "?" char, how can I let X-term window output the unicode for that char ? If I can do that, then I will be able to know what special character it is.
Thanks,
steve
Siddharth Mehrotra
Ranch Hand

Joined: Aug 21, 2001
Posts: 185
HI, I had the same probelm on AIX, It displayed all chineese charachters as ?? , all I did was that before running the program I used to set the Locale of the session so that it understood the language, like i used to set Lang to zh_tw.Big5.
there must something similar for your choice of language


SCJP, SCJD.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I handle string match with these Puerto Rico cities (spanish) ?