开发者

Decode unicode chracters in HTML in ASP.NET

I have a string that represents an HTML block. All the unicode characters are encoded. So it takes lots of spaces when inserted to database. For example: <p>thích</p> is saved as <p>th&iacute;ch</p> How can I decode those unicode 开发者_JAVA百科characters? I cannot use HttpUtility.HtmlDecode because it will decode some other characters like > or < as well, which I still want it to be encoded.


What about just manually re-encoding the non-unicode specific characters?

Server.HtmlDecode(str).Replace("<","&lt;")
                      .Replace(">","&gt;")
                      .Replace("&","&amp;")
                      .Replace("\"","&quot;")
                      .Replace("\'","&#39;")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜