Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly decode accented characters for display

My raw input file text file contains a string:

Caf&eacute (Should be Café)

The text file is a UTF8 file.

The output lets say is to another text file, so its not necessarily for a web page.

What C# method(s) can i use to output the correct format, Café?

Apparently a common problem?

like image 577
Fixer Avatar asked Jan 18 '23 02:01

Fixer


2 Answers

Have you tried System.Web.HttpUtility.HtmlDecode("Café")? it returns 538M results

like image 152
L.B Avatar answered Jan 22 '23 10:01

L.B


This is HTML encoded text. You need to decode it:

string decoded = HttpUtility.HtmlDecode(text);

UPDATE: french symbol "é" has HTML code "é" so, you need to fix your input string.

like image 34
Sergey Berezovskiy Avatar answered Jan 22 '23 08:01

Sergey Berezovskiy