转换和放大器; #____到\ ____ü用C#? [英] Convert &#____ to \u____ in c#?
问题描述
我要显示一个特殊字符。
I want to show a special character.
我发现这个<一href="http://amp-what.com/?tagline=Search%3Cbr%3EUni$c$c%20Characters&utm_expid=63334077-0&utm_referrer=http://t.co/oklb2ro0#q=arrow"相对=nofollow>链接,显示一切。
让我们就拿这个字符:
2的问题)
-
我怎么可以转换
&放大器; darr;
,&放大器;#8595;
到\û____
UNI code字符? (C#)
how can I convert
↓
,↓
to\u____
unicode char ? ( c#)
当我应该用&放大器; darr;
VS &放大器;#8595;
推荐答案
您可以使用:
System.Net.WebUtility.HtmlDecode("↓")
System.Net.WebUtility.HtmlDecode("↓")
以上是.NET 4.0及以上,对于之前的版本,使用 System.Web.HttpUtility
。
两者都将产生包含字符串↓
。
Both will produce a string containing ↓
.
您可以把这个字符串,得到的第一个(也是唯一一个)从它的性格 - 这将是C#,UTF16字符
You can take this string, get the first (and only) character from it - this will be a C#, UTF16 character.
我会建议使用&放大器; darr;对
而不是数字字符引用如果必须使用字符引用,因为它是更具可读性。如果您可以使用↓
直接,那就是最好的。
I would suggest using ↓
instead of the numeric character reference if you must use character references, as it is more readable. If you can use the ↓
directly, that is best.
这篇关于转换和放大器; #____到\ ____ü用C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!