This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
all events occur in real time
Joined: Oct 03, 2005
Yeah even i was thinking its because of encoding.
My problem is when, i get the value from DB and make the key out of it. I dont know how it is stored in DB. and when i get from Hashmap using this DB data, its coming as null.
Then in that case, how do i put thai data into the hashmap. I dont have any primary key to use also.
Joined: Aug 05, 2005
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().
Joined: Oct 03, 2005
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.