文本格式(很抱歉,我无法编辑我的帖子) [英] Text Format (srry aout the double post but i cant edt my post)
问题描述
这是我的问题的一个示例:
我正在尝试转换此字符串->测试\ x26#39;好的
对此->测试''OK
即时通讯使用webClient从网站获取字符串
我得到的字符串在C#中有特殊字符,就像这样" test \ x26#39;好的''
所以如何将它们转换为纯文本->测试''OK
不起作用
///////////////////
here is an example of my problem:
im trying to convert this string -> test \x26#39; ok
to this -> test '' ok
im using a webClient to get string from site
the string i get have special characters wich show in C# like this ''test \x26#39; ok''
so how can i convert them to Plain Text -> test '' ok
Not Working
/////////////////////
string kk = @"test \x26#39; ok";
textBox25.Text = kk; //text box value = test \x26#39; ok
string result = HttpUtility.HtmlDecode(textBox25.Text);
//result = test \x26#39; ok - same thing////
工作
////////////////////////
Working
/////////////////////////////////////////
string kk = "test \x26#39; ok";
textBox25.Text = kk; //text box value = test ' ok -----Note The Cange
string result = HttpUtility.HtmlDecode(textBox25.Text);
//result = test ' ok -- this is the value im trying to get
所以问题是我无法将\ x26#39转换为'
预先装上坦克
双重帖子的广告
so the problem is i cant convert \x26#39 to '
tanks in advance
ad srry for the double post
推荐答案
您的解决方案可能非常简单:删除字符串开头的"@"!
当您编写代码时,例如:
Your solution is probably pretty simple: remove the ''@'' at the start of your string!
When you write code such as:
string kk = @"test \x26#39; ok";
它将一个16字符串分配给"kk"-前缀"@"表示忽略所有反斜杠字符-它们不是转义码".但这就是问题所在.您希望反斜杠作为前缀,以便将序列"\ x26"识别为字符&".
那么您的字符串将只有13个字符长:
HpmlDecode将其识别为单引号字符的值的
It assigns a 16 character string to "kk" - the ''@'' prefix says "ignore all backslash characters - they are not escape codes". But that''s the problem. You want the backslash to be a prefix, so that the sequence "\x26" is recognised as a character ''&''.
Then your string will be only 13 characters long:
"test ' ok"
.
这篇关于文本格式(很抱歉,我无法编辑我的帖子)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!