-1

如何将 HTML 特殊字符编码为它们的实际值?

数据:

Antique bronze of an archer by Franz Iffland Literature:
“Bronzes, sculptors and founders” by H. Berman, Abage. 
“Dictionnaire illustré des sculpteurs animaliers & fondeurs de l’antiquité à nos jours “ by Jean Charles Hachet. Argus Valentines. 
“The dictionary of sculptors in bronze” by James Mackay. Antique collectors club. 
 Fedex shipping: $ 185


所需输出:

Antique bronze of an archer by Franz Iffland Literature:
“Bronzes, sculptors and founders” by H. Berman, Abage. 
“Dictionnaire illustré des sculpteurs animaliers & fondeurs de l’antiquité à nos jours “ by Jean Charles Hachet. Argus Valentines. 
“The dictionary of sculptors in bronze” by James Mackay. Antique collectors club. 
 Fedex shipping: $ 185
4

4 回答 4

4

使用HtmlDecode

string source ="Antique bronze of an archer by Franz Iffland Literature:
“Bronzes, sculptors and founders” by H. Berman, Abage. 
“Dictionnaire illustré des sculpteurs animaliers & fondeurs de l’antiquité à nos jours “ by Jean Charles Hachet. Argus Valentines. 
“The dictionary of sculptors in bronze” by James Mackay. Antique collectors club. 
 Fedex shipping: $ 185";

string decoded= WebUtility.HtmlDecode(source);
于 2013-05-22T11:15:06.620 回答
2

您可以使用

 string output = WebUtility.HtmlDecode(Data);

它位于System.Net命名空间下。

于 2013-05-22T11:13:44.333 回答
1

使用HttpUtility.HtmlDecodeWebUtility.HtmlDecode

string s = "Antique bronze of an archer by Franz Iffland Literature:
“Bronzes, sculptors and founders” by H. Berman, Abage. 
“Dictionnaire illustré des sculpteurs animaliers & fondeurs de l’antiquité à nos jours “ by Jean Charles Hachet. Argus Valentines. 
“The dictionary of sculptors in bronze” by James Mackay. Antique collectors club. 
 Fedex shipping: $ 185";
var s2 = HttpUtility.HtmlDecode(s);
var s3 = WebUtility.HtmlDecode(s);
于 2013-05-22T11:14:00.307 回答
1
string res = Server.HtmlDecode("ntique bronze of an archer by Franz Iffland Literature:
“Bronzes, sculptors and founders” by H. Berman, Abage. 
“Dictionnaire illustré des sculpteurs animaliers & fondeurs de l’antiquité à nos jours “ by Jean Charles Hachet. Argus Valentines. 
“The dictionary of sculptors in bronze” by James Mackay. Antique collectors club. 
 Fedex shipping: $ 185");
于 2013-05-22T11:15:18.653 回答