I won't say much nonsense, let's just read the code~
encodeURIComponent('\n') "%0A" encodeURIComponent('\\') "%5C" encodeURIComponent('/') "%2F" encodeURIComponent(',') "%2C" encodeURIComponent('\'') %27 encodeURIComponent("\"")"%22" data = json; data = ("\\", "%5C").Replace("\n", "%0A");//.Replace("/","%2F"); .Replace(",", "%2C").Replace("'", "%27").Replace("\\", "%5C").Replace("\n", "%0A") encodeURIComponent("\"") "%22" encodeURIComponent('\\') "%5C"
Supplement: Processing of Xml special characters in C#
The following are the corresponding entities of several special characters.
< |
< |
Less than |
> |
> |
Greater than |
& |
& |
and |
' |
' |
Single quotes |
" |
" |
Double quotes |
In C#, the methods provided by C# are called directly, and after saving, special characters will be automatically converted to the corresponding entity:
string s =(s);
The above is personal experience. I hope you can give you a reference and I hope you can support me more. If there are any mistakes or no complete considerations, I would like to give you advice.