How can I convert this string:
This string contains the Unicode character Pi(π)
into an escaped A
As a one-liner:
var result = Regex.Replace(input, @"[^\x00-\x7F]", c => string.Format(@"\u{0:x4}", (int)c.Value[0]));