// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Security; using System.Web; using System.Xml; namespace E { public class Program { public static void Main(string[] args) { string s = "http://test.dk/PermalinkViewer.htmx?viewId=1&linkType=htmlType"; Console.WriteLine(s); string s1 = HttpUtility.UrlEncode(s); Console.WriteLine(s1); string s2 = SecurityElement.Escape(s); Console.WriteLine(s2); using(XmlWriter xw = XmlTextWriter.Create(Console.Out)) { xw.WriteStartDocument(); xw.WriteElementString("url", s); xw.WriteEndDocument(); } } } }