Reading strings in Unicode

Hi, I have a Java application that reads data from the console and prints it.

If I enter a Unicode string in the Console, for example \ u06F1, it will print \ u06F1 instead of "?".

What change should I make to the code to display the character as "?".

thank

+3
source share
1 answer

Generally speaking, you should do the following

  • use regex to find all occurrences of the following:

    \ and [0-9a-FA-F] {4};

  • Then you should use Integer.parseInt()the numeric part;

  • Finally, you must replace the string with an integer by char.

Does that make sense to you?

0
source

Source: https://habr.com/ru/post/1774025/


All Articles