Unicode characters string

Viewed 24630

I have the following String of characters.

string s = "\\u0625\\u0647\\u0644";

When I print the above sequence, I get:

\u0625\u0647\u062

How can I get the real printable Unicode characters instead of this \uxxxx representation?

5 Answers

Asker posted this as an answer to their question:

I have found the answer:

s = System.Text.RegularExpressions.Regex.Unescape(s);

I had the following string "\u0001" and I wanted to get the value of it.
I tried a lot but this is what worked for me

int val = Convert.ToInt32(Convert.ToChar("\u0001")); // val = 1;

if you have multiple chars you can use the following technique

var original ="\u0001\u0002";
var s = "";
for (int i = 0; i < original.Length; i++)
{
    s += Convert.ToInt32(Convert.ToChar(original[i]));
}

// s will be "12"
Related