3

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 is printing \u06F1 instead of "?".

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

Thanks

dplante
  • 2,445
  • 3
  • 21
  • 27
Ganesh
  • 131
  • 3

1 Answers1

0

Generally speaking, you should do the following

  • use a regex to find all occurrences of the following:

    \u[0-9a-fA-F]{4};

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

  • finally you should replace the string with the integer cast to a char.

Does this make sense to you?

dplante
  • 2,445
  • 3
  • 21
  • 27
jcomeau_ictx
  • 37,688
  • 6
  • 92
  • 107