I have a string with escaped Unicode characters, \uXXXX, and I want to convert it to regular Unicode letters. For example:
"\u0048\u0065\u006C\u006C\u006F World"
should become
"Hello World"
I know that when I print the first string it already shows Hello world. My problem is I read file names from a file, and then I search for them. The files names in the file are escaped with Unicode encoding, and when I search for the files, I can’t find them, since it searches for a file with \uXXXX in its name.
Technically doing:
automatically converts it to
"Hello World", so I assume you are reading in the string from some file. In order to convert it to “Hello” you’ll have to parse the text into the separate unicode digits, (take the\uXXXXand just getXXXX) then doInteger.ParseInt(XXXX, 16)to get a hex value and then case that tocharto get the actual character.Edit: Some code to accomplish this: