1

I would like to create a map with japanese character. eg,

    Map<String, String> map = new HashMap<String, String>();
    map.put("あ","ア");
    map.put("え","イ");
    map.put("お","オ");
    map.put("え","エ");
    map.put("お","オ");
    String str = "あaいiうuえeおo";

Result = アaイiウuエeオo

But I want to put only unicode for japanese characters and I want to compare input string with key of map, then change it to respective value. How do I change each letter of String str to unicode. How do I compare each letter in a String with keys of a Map using unicode? If each letter exists as a key of the map, change it with respective map value. Thanks.

  • If I am parsing things correctly, I think you can use the Unicode code points instead of the characters. The codepoints are the values like `U+0000`. Also see [Unicode Codepoint Chart](http://inamidst.com/stuff/unidata/). – jww Feb 23 '17 at 06:32
  • Thanks for advice. :D –  Feb 23 '17 at 06:57

1 Answers1

0

You can loop through each of the keys in your map and call String#replaceAll() for each of the respective keys and values.

As for turning the resulting value into unicode you can view this post: Get unicode value of a character.

Community
  • 1
  • 1
Liam Lutton
  • 204
  • 2
  • 8
  • String#replaceAll() replaces all the letters. I just want to replace only the letter which includes in key of map. Anyway, Thanks :D –  Feb 23 '17 at 06:56