I have a string which looks like:
À l'intérieur
But it needs to be:
À l'intérieur
I tried changing the conversion. I know it's read as ASCII encoding. So I tried using the code:
ASCIIEncoding ASCII = new System.Text.ASCIIEncoding();
Byte[] BytesMessage = ASCII.GetBytes(Title);
Title = Encoding.UTF8.GetString(BytesMessage);
I tried switching between the different encodings but it didn't help much. Is there a way to fix this?
Thx!
Well, this is actually not a character encoding (such as ASCII or UTF-8) but rather a higher-level protocol defining escape sequences for arbitrary characters—in this case SGML which serves as the basis for HTML and XML.
You can use the HtmlDecode method of the HttpUtility class to decode it:
PS> Add-Type -AssemblyName system.web
PS> [web.httputility]::HtmlDecode("À l'intérieur")
À l'intérieur
However, this class resides in the System.Web namespace so it's probably not immediately available in a non-ASP.NET project.
To transcode HTML encoded strings like this use System.Web.HttpUtility.HtmlDecode(Title). You'll need to reference System.Web if this is not a Web application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With