CSharp examples for System:String HTML
Html Encode
using System;// w w w .j a v a 2 s . c o m public class Main{ public static String HtmlEncode(String source, Int32 spaceCount, Boolean replaceTab, Boolean replaceEnter) { if (String.IsNullOrEmpty(source)) { return String.Empty; } String dest = source; dest = dest.Replace("&", "&"); dest = dest.Replace("<", "<"); dest = dest.Replace(">", ">"); dest = dest.Replace("\"", """); if (spaceCount > 0) { String srcSpace = new String(' ', spaceCount); String dstSpace = srcSpace.Replace(" ", " "); dest = dest.Replace(srcSpace, dstSpace); } if (replaceTab) { dest = dest.Replace("\t", " "); } if (replaceEnter) { dest = dest.Replace(Environment.NewLine, "<br/>"); } return dest; } public static String HtmlEncode(String source) { return HtmlEncode(source, 0, false, false); } }