Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have the following String of characters.

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

When I print the above sequence, I get:

u0625u0647u062

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


I have found the answer:

s = System.Text.RegularExpressions.Regex.Unescape(s);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
110 views
Welcome To Ask or Share your Answers For Others

1 Answer

If you really don't control the string, then you need to replace those escape sequences with their values:

Regex.Replace(s, @"u([0-9A-Fa-f]{4})", m => ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString());

and hope that you don't have \ escapes in there too.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...