PivotalTrackerAPI/Util/WebEncoding.cs
/// <summary>
/// HTML-encodes a string and returns the encoded string.
/// </summary>
/// <param name="text">The text string to encode. </param>
/// <returns>The HTML-encoded text.</returns>
HTML-encodes a string and returns the encoded string.
HTML - encodes a string and returns the encoded string .
public static string HtmlEncode(string text)
    {
        if (text == null)
            return null;
        StringBuilder sb = new StringBuilder(text.Length);
        int len = text.Length;
        for (int i = 0; i < len; i++)
        {
            switch (text[i])
            {
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                case '&':
                    sb.Append("&amp;");
                    break;
                default:
                    if (text[i] > 159)
                    {
                        sb.Append("&#");
                        sb.Append(((int)text[i]).ToString(CultureInfo.InvariantCulture));
                        sb.Append(";");
                    }
                    else
                        sb.Append(text[i]);
                    break;
            }
        }
        return sb.ToString();
    }
public static string HtmlEncode ( string text ) { if ( text == null ) return null ; StringBuilder sb = new StringBuilder ( text . Length ) ; int len = text . Length ; for ( int i = 0 ; i < len ; i ++ ) { switch ( text [ i ] ) { case ' ' : sb . Append ( " " ) ; break ; case ' ' : sb . Append ( " " ) ; break ; case ' ' : sb . Append ( " " ) ; break ; case ' ' : sb . Append ( " " ) ; break ; default : if ( text [ i ] > 159 ) { sb . Append ( " " ) ; sb . Append ( ( ( int ) text [ i ] ) . ToString ( CultureInfo . InvariantCulture ) ) ; sb . Append ( " " ) ; } else sb . Append ( text [ i ] ) ; break ; } } return sb . ToString ( ) ; }
HTML-encodes a string and returns the encoded string.
HTML - encodes a string and returns the encoded string .
// decimal numeric entity
The HTML-encoded text.
The HTML - encoded text .
text
string
The text string to encode.
The text string to encode .