0

I currently have a UTF8 string that contains nulls, backspaces, etc. inside the string. I am trying to escape the string so that control characters are visible in their escaped form. Basically, the input/output I want looks like this:

String inString = "String\u0000 with\u0008 stuff \u000a in it";
String outString = "String\\0 with\\b stuff \\n in it";

I don't want to write a regex searching for all the escape characters, but I couldn't seem to find any inbuilt functions to do this. Is regex my only option?

Thanks!

Jeff Geisperger
  • 583
  • 4
  • 17
  • 1
    I don't believe there is one in framework. [Regex.Replace(string, string, MatchEvaluator)](http://msdn.microsoft.com/en-us/library/ht1sxswy(v=vs.110).aspx) would indeed be my choice (avoids building string back myself)... – Alexei Levenkov Aug 11 '14 at 21:44
  • Side note: You may want to clarify how "UTF8" should be taken into account... – Alexei Levenkov Aug 11 '14 at 21:47

0 Answers0