using System.Globalization;
namespace YY.Admin.Core.Util
{
public class StringUtil
{
///
/// HTML实体编码转换为C#/WPF支持的Unicode转义格式
///
///
///
public static string ConvertHtmlEntityToUnicode(string htmlEntity)
{
if (string.IsNullOrEmpty(htmlEntity))
return string.Empty;
if (htmlEntity.StartsWith("") && htmlEntity.EndsWith(";"))
{
string hexCode = htmlEntity.Substring(3, htmlEntity.Length - 4);
if (int.TryParse(hexCode, NumberStyles.HexNumber, null, out int unicodeValue))
{
return char.ConvertFromUtf32(unicodeValue);
}
}
return htmlEntity;
}
}
}