Skip to main content
 首页 » 编程设计

c#之在 web.config 值中使用 HTML 下标

2024年04月30日36bhlsheji

我想要一个文本中的子字符串,它应该像 ABC2XYZ

所以我在获取值的 web.config 中如下使用它

在 Web.config 中

<add key="Name" value="ABC&lt;sub&gt;2 &lt;/sub&gt;XYZ" /> 

在 Layout.cshtml 中

<title id="Title">@(string.Format("{0} - {1}", HttpUtility.HtmlDecode(ConfigurationManager.AppSettings["Name"]), ViewBag.Title))</title> 

但最终的文本输出显示为 ABC2XYZ 而不是子字符串。您能否帮我解决这个问题,或者您能否提出任何其他实现方法。

请您参考如下方法:

尝试使用与下标 2 等效的 unicode,“U+2082”。

<add key="Name" value="ABC&#x2082;XYZ" /> 

https://www.w3.org/TR/unicode-xml/

http://unicode.org/charts/PDF/U2070.pdf