在很多 網站(或者很多 WebService),
我們總能看到 Ӓ &#A22A; 這種格式 的編碼。
如何將這種編碼 轉換成 實際文本,C#代碼如下:
1 //各種 幺蛾子網頁圖標 請參見: https://dev.w3.org/html5/html-author/charref 2 3 string str = "中国"; 4 string str2 = "中国"; 5 string str3 = "♣♣♣♣█"; 6 7 8 string decode = System.Web.HttpUtility.HtmlDecode(str); 9 Console.WriteLine(decode); //中國 10 decode = System.Web.HttpUtility.HtmlDecode(str2); 11 Console.WriteLine(decode); //中國 12 decode = System.Web.HttpUtility.HtmlDecode(str3); 13 Console.WriteLine(decode); //♣♣♣♣█ //有些 ♣ 格式, 識別不了. 14 15 Console.WriteLine(System.Web.HttpUtility.HtmlEncode("我愛中國")); //不會被再次轉義為 � 格式
最后的廢話:
> ࢮ 這種編碼 是 UTF8 網頁編碼時用到。
> 這類編碼 和 ≶ &tg; 這類編碼 基本是 一伙的。
> 但: ࢮ 這類編碼 目測毫無價值。