[Modify] Add it

This commit is contained in:
sta 2018-09-30 17:58:37 +09:00
parent 1c2472c9f3
commit f8a70130e7

View File

@ -155,6 +155,29 @@ namespace WebSocketSharp.Net
return buff.ToString ();
}
private static string htmlEncode (string s)
{
var buff = new StringBuilder ();
foreach (var c in s) {
buff.Append (
c == '"'
? """
: c == '&'
? "&"
: c == '<'
? "&lt;"
: c == '>'
? "&gt;"
: c > 159
? String.Format ("&#{0};", (int) c)
: c.ToString ()
);
}
return buff.ToString ();
}
private static void initEntities ()
{
// Build the dictionary of HTML entity references.