Escape Accents To HtmlEntity as Hex
<p>This is my unicode String 
></p>

<blockquote>
  <p>Désastres</p>
</blockquote>

<p>The above String need to be converted to HTML Entity (Hex) as  </p>

<p><code>D&amp;#x00E9;sastres</code></p>

<p>Below is the code, it converts the string to html entiry but in Decimal.</p>

<p>Can anyone help me to get the desired result?</p>

<pre><code>static string EscapeAccentsToHtmlEntities(string source)
{
    int length = source.Length;
    var escaped = new StringBuilder();

    for (int i = 0; i &lt; length; i++)
    {
        char ch = source[i];

        if ((ch &gt;= '\x00a0') &amp;&amp; (ch &lt; 'Ā')) //U+{0:X4} 
        {
            escaped.AppendFormat("&amp;#{0};", ((int)ch).ToString(NumberFormatInfo.InvariantInfo)); //"&amp;#{0};"
        }
        else
        {
            escaped.Append(ch);
        }
    }

    return escaped.ToString();
}
</code></pre>

<p>Explaination:
possible duplicates of <a href="https://stackoverflow.com/questions/6639770/how-do-i-get-the-unicode-hex-representation-of-a-symbol-out-of-the-html-using-ja">this</a> is for javascript / jquery</p>