Programming language: Java Task: creating a hash function that maps Chinese strings to numbers Problem: reading and displaying Chinese characters correctly
This is a homework question, but I am not asking how to do it, just having problems with the implementation of reading Chinese characters.
A brief description of my task: to create a hash function for matching the (Chinese) names of students in our class with their student identifiers and other satellite data (gender, phone, etc.).
I still think about it, but like other languages, the scope of me includes the use of character encoding of a character, through a hash function, come up with a unique value, if I'm not mistaken,
Here is what I should check for the validity of this thought movement:
// test whether console can read chinese characters Scanner s = new Scanner(System.in); System.out.print("Please enter a Chinese character: "); int chi = (int)s.next().toCharArray()[0]; System.out.println("\nThe string entered is " + chi);
If I use the simple System.out.println ("character") statement, the correct character is displayed.
But as seen above, if I use Scanner to read input, I tried to convert String to a char array, and then its equivalent is un unicode, but it calls a ridiculous number and I canβt display it correctly.
I understand that I can just use this erroneous value to create a hash function, but in order not to create possible collisions (I donβt know if they produce UNIQUE erroneous values) and for the sake of training, could you indicate how I can combine entering Chinese characters on different machines?
Always grateful for your thoughts .: D
Baggio.