HttpUtility.HtmlDecode难题 string l = textBox1.Text;string c = HttpUtility.HtmlDecode(l);MessageBox.Show(c);假设文本框中输入的是\u7f51\u7edc\u7535\u8bdd,但这里输出的还是\u7f51\u7edc\u7535\u8bdd,并没有解码如何才能解码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 System.Web.HttpUtility.HtmlAttributeEncode(textBox1.Text); 我的要求是在文本框中输入\u7f51\u7edc\u7535\u8bdd,然后取文本框中的值解码! 3楼的没看清楚!4楼的效果没变,还是输出\u7f51\u7edc\u7535\u8bdd。 Regex reg = new Regex(@"(?i)\\[uU]([0-9a-f]{4})");string s=reg.Replace(SourceString, delegate(Match m) { return ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString();Console.Write("\u7f51\u7edc") 网络 private void button1_Click(object sender, EventArgs e) { string _TextPear = DecodeUnicode(textBox1.Text); } public string DecodeUnicode(string p_Text) { string _ReturnValue = p_Text; System.Text.RegularExpressions.MatchCollection _Collection = new System.Text.RegularExpressions.Regex(@"(?<=\\u)(\w{4,16})+").Matches(p_Text); foreach (System.Text.RegularExpressions.Match _Match in _Collection) { char _Char =(char)Convert.ToUInt16(_Match.Value,16); _ReturnValue=_ReturnValue.Replace("\\u" + _Match.Value, _Char.ToString()); } return _ReturnValue; } 谢谢zgke,非常感谢。用你10楼的代码OK了! 请教问题 关于论坛发布帖子问题 我运行asp.net的ip为:111.11.11.1,我想通过HtmlInputFile在ip为:111.11.11.2的计算机上建文件夹,应该怎么做呢? 连接ORACLE出错 推荐一下用VS.NET开发ASP.NET实例的电子书,关键是要介绍VS.NET如何开发文档的,谢谢 函数调用问题,请大家帮看看 请高手看过来!!!!急!!! 如何直接得到DataTable中第一行第一列的值 初次使用TreeView,遇到一点问题 PDF在线预览 如何将数据库已有的关键字,在网页上自动显示为超链接。。 GridView 删除与行单击问题
string s=reg.Replace(SourceString, delegate(Match m) { return ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString();
Console.Write("\u7f51\u7edc") 网络
{
string _TextPear = DecodeUnicode(textBox1.Text);
}
public string DecodeUnicode(string p_Text)
{
string _ReturnValue = p_Text;
System.Text.RegularExpressions.MatchCollection _Collection = new System.Text.RegularExpressions.Regex(@"(?<=\\u)(\w{4,16})+").Matches(p_Text);
foreach (System.Text.RegularExpressions.Match _Match in _Collection)
{
char _Char =(char)Convert.ToUInt16(_Match.Value,16);
_ReturnValue=_ReturnValue.Replace("\\u" + _Match.Value, _Char.ToString());
} return _ReturnValue;
}