System.Xml.Xsl.Runtime.XsltFunctions.Translate C# (CSharp) Method

Translate() public static method

public static Translate ( string arg, string mapString, string transString ) : string
arg string
mapString string
transString string
return string
        public static string Translate(string arg, string mapString, string transString)
        {
            if (mapString.Length == 0)
            {
                return arg;
            }

            StringBuilder sb = new StringBuilder(arg.Length);

            for (int i = 0; i < arg.Length; i++)
            {
                int index = mapString.IndexOf(arg[i]);
                if (index < 0)
                {
                    // Keep the character
                    sb.Append(arg[i]);
                }
                else if (index < transString.Length)
                {
                    // Replace the character
                    sb.Append(transString[index]);
                }
                else
                {
                    // Remove the character
                }
            }
            return sb.ToString();
        }