转换嵌入的unicode字符

时间:2019-01-08 06:47:28

标签: c# asp.net-mvc parsing unicode

所以我有一些要从API中提取的数据,当我将其提取到描述字符串中时,它最终嵌入了&nbsp,&mdash,&#10和其他各种unicode字符。当我将其推送到html页面时,它最终会显示在视图上。如何将其转换为可读的字符串?

这是我需要在视图中还是在控制器上的字符串中解析的东西?

3 个答案:

答案 0 :(得分:2)

您可以使用System.Web.HttpUtility类中的HtmlDecode方法

^(?=.*\..*\.).*$

答案 1 :(得分:1)

如果确定字符串是有效的HTML,则可以在视图中使用@Html.Raw(yourString)将字符串显示为HTML;如果信任源,并且确定不会使用该字符串,则可以使用进行XSS攻击。

答案 2 :(得分:-2)

您可以使用此代码从conn = sqlite3.connect('db_employees.db') c = conn.cursor() query = "SELECT * FROM tb_emp_info" c.execute(query) result = c.fetchall() in_ = 'Permanent', # 'Permanent' is present in the database print(in_ in result) # check if input is present in the database 中删除那些character

html string