Posted By

pillow86 on 08/16/11


Tagged

unicode characters chinese


Versions (?)

Convert Unicode Escape Sequence to Character


 / Published in: C#
 

Convert "\u6211" to "我"

  1. public static string UnicodeToCharacter(string inStr)
  2. {
  3. string result = inStr;
  4. if (Regex.Match(inStr, @".*\\u.*").Success)
  5. {
  6. Regex rx = new Regex(@"\\[uU]([0-9A-F]{4})");
  7. result = rx.Replace(result, delegate(Match match) { return ((char)Int32.Parse(match.Value.Substring(2), NumberStyles.HexNumber)).ToString(); });
  8. }
  9. return result;
  10. }

Report this snippet  

You need to login to post a comment.