I am facing a problem while storing and retrieving thai data in a hashmap. I have both the key and value as thai data. When I want to retrieve value from the hashmap giving the key as thai data, it is not fetching the value. I mean, no value is getting returned even though the data matches. I checked by giving the key as English data, its giving out the result properly.
I understand that there could be a difference while constructing a thai word, where the character sequence can be different. In this case how can I put and get data from a Hashmap.
perhaps �dne could you please check on your system, what values the question marks really stand for?
I thing the problem has nothing to do with HashMaps but with the encoding. Sorry, I can't find a solution, but maybe have a look (or two) on this: prints i 0 char X value 88 i 1 char Y value 89 i 2 char value 32 i 3 char ? value 63 i 4 char ? value 63 i 5 char ? value 63 i 6 char ? value 63 i 7 char ? value 63 i 8 char ? value 63
All thai letters became int value 63!
--- At least Cthul where is Providence Rhode Island
Have you tried comparing the two strings - a.equals(b), where a is user input string and b is string read from database? If this returns false (which I think will happen), you should try to make a Key class congtaining the key strings, overriding the equals() method (where you compare the two and "manually" determines if they are equal or not). PS if you override equals you also need to override hashCode().
I found the problem in file reading. I didnt open the file with UTF-8. what i was doing is, getting the values from File in normal encoding and puting into the hashmap. These values were going in junk. When i compare with valid thai value, its giving out null.
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop