crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianUtils/Utilities/HTMLEntityUtility.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 using System;
       
    18 using System.Text;
       
    19 
       
    20 namespace SymbianUtils
       
    21 {
       
    22 	public class HTMLEntityUtility
       
    23 	{
       
    24 		public static string Entitize(string text)
       
    25 		{
       
    26 			return Entitize(text, true);
       
    27 		}
       
    28 
       
    29 		public static string Entitize( string aText, bool aEntitizeQuotAmpAndLtGt)
       
    30 		{
       
    31 			StringBuilder ret = new StringBuilder( aText.Length );
       
    32 
       
    33 			for(int i=0;i<aText.Length;i++)
       
    34 			{
       
    35 				int code = (int) aText[i];
       
    36 				if ( (code > 127 || code < 32 ) || (aEntitizeQuotAmpAndLtGt && ((code == 34) || (code == 38) || (code == 60) || (code == 62))))
       
    37 				{
       
    38 					ret.Append( "&#" + code + ";" );
       
    39 				}
       
    40 				else if ( aText[i] == '\'' || aText[i] == '@' || aText[i] == '\"' )
       
    41 				{
       
    42 					ret.Append( "." );
       
    43 				}
       
    44 				else
       
    45 				{
       
    46 					ret.Append( aText[i] );
       
    47 				}
       
    48 			}
       
    49 
       
    50 			return ret.ToString();
       
    51 		}
       
    52 	}
       
    53 }