Skip to content

Instantly share code, notes, and snippets.

@bolenton
Created July 18, 2017 01:36
Show Gist options
  • Save bolenton/03c7df00d9c220433c8932e11b0fa86c to your computer and use it in GitHub Desktop.
Save bolenton/03c7df00d9c220433c8932e11b0fa86c to your computer and use it in GitHub Desktop.
public static string RemoveSpecialSymbols(this string mystring)
{
JObject j = new JObject();
j.Add(new JProperty("", mystring));
//string s = j.First.Value<string>();
var sr = new StringWriter();
var jsonWriter = new JsonTextWriter(sr)
{
StringEscapeHandling = StringEscapeHandling.EscapeNonAscii
};
new JsonSerializer().Serialize(jsonWriter, j[""]);
var newString = sr.ToString();
var resultString = Regex.Replace(newString, "\\\"", "");
return resultString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment