MarkdownSharp.Markdown.EncodeProblemUrlChars C# (CSharp) Method

EncodeProblemUrlChars() private method

hex-encodes some unusual "problem" chars in URLs to avoid URL detection problems
private EncodeProblemUrlChars ( string url ) : string
url string
return string
        private string EncodeProblemUrlChars(string url)
        {
            if (!_encodeProblemUrlCharacters) return url;

            var sb = new StringBuilder(url.Length);
            bool encode;
            char c;

            for (int i = 0; i < url.Length; i++)
            {
                c = url[i];
                encode = Array.IndexOf(_problemUrlChars, c) != -1;
                if (encode && c == ':' && i < url.Length - 1)
                    encode = !(url[i + 1] == '/') && !(url[i + 1] >= '0' && url[i + 1] <= '9');

                if (encode)
                    sb.Append("%" + String.Format("{0:x}", (byte)c));
                else
                    sb.Append(c);                
            }

            return sb.ToString();
        }