示例#1
0
        public string Canonicalize(string input)
        {
            StringBuilder stringBuilder = new StringBuilder();

            Encoder.EncodedStringReader encodedStringReader = new Encoder.EncodedStringReader(input);
            while (encodedStringReader.HasNext())
            {
                Encoder.EncodedCharacter nextCharacter = encodedStringReader.NextCharacter;
                if (nextCharacter != null)
                {
                    stringBuilder.Append(nextCharacter.Unencoded);
                }
            }
            return(stringBuilder.ToString());
        }
示例#2
0
        private string EntityEncode(string input, char[] baseChars, char[] immune)
        {
            StringBuilder stringBuilder = new StringBuilder();

            Encoder.EncodedStringReader encodedStringReader = new Encoder.EncodedStringReader(input);
            while (encodedStringReader.HasNext())
            {
                Encoder.EncodedCharacter nextCharacter = encodedStringReader.NextCharacter;
                if (nextCharacter != null)
                {
                    if (this.IsContained(baseChars, nextCharacter.Unencoded) || this.IsContained(immune, nextCharacter.Unencoded))
                    {
                        stringBuilder.Append(nextCharacter.Unencoded);
                    }
                    else
                    {
                        stringBuilder.Append(nextCharacter.GetEncoded(3));
                    }
                }
            }
            return(stringBuilder.ToString());
        }