Quantcast
Channel: HTML Renderer
Viewing all articles
Browse latest Browse all 693

New Post: Crash in DecodeHtmlCharByCode

$
0
0
This appears to fix it. I don't THINK it has downstream implications, but it's working for me:
        private static string DecodeHtmlCharByCode(string str)
        {
            var idx = str.IndexOf("&#");
            while (idx > -1)
            {
                var endIdx = idx + 2;
                long num = 0;
                while (endIdx < str.Length && char.IsDigit(str[endIdx]))
                    num = num * 10 + str[endIdx++] - '0';
                endIdx += (endIdx < str.Length && str[endIdx] == ';') ? 1 : 0;

                str = str.Remove(idx, endIdx - idx);
                str = str.Insert(idx, Convert.ToChar(num).ToString());

                idx = str.IndexOf("&#", idx);
            }
            return str;
        }

Viewing all articles
Browse latest Browse all 693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>