你Microsoft.Security.Application.AntiXss.HtmlEncode什么时候打电话?您是在用户提交信息时执行此操作还是在显示信息时执行此操作?
如姓名,姓氏,城市,州,邮编等基本内容怎么样?
我是asp.net的新手,在使用gridview时遇到了问题.
我添加了一些包含"&"符号的条目,例如"PR Murphy&Associates".在将数据插入数据库之前,我没有对数据进行任何编码.
当gridview更改为编辑模式时,我的文本如下所示:"PR Murphy&Associates"
这是一种我可以阻止它编码信息的方式,我的意思是在插入时将文本保留为"PR Murphy&Associates",然后在编辑之后/之后.
感谢您
我有一个文本区域,我想接受文本区域的输入并将它们合并在一起.一切正常,但它正在逃避报价.例如test's输出为test/'s
为了解决这个问题,我试过了很多例子,
<?php $inputtext= $_POST['textinput'];
$encodetext = htmlentities($inputtext);
$finaltext = html_entity_decode($encodetext);
echo '<p>'.$finaltext .'</p>'; ?>
Run Code Online (Sandbox Code Playgroud)
这应该根据html_entity_decode手册工作(除非我读错了,很可能是这种情况)
我对str_replace有一个非常微不足道的问题.
我有一个带有En Dash字符的字符串( - ),如下所示:
I want to remove - the dash
Run Code Online (Sandbox Code Playgroud)
html输出是
I want to remove the – the dash
Run Code Online (Sandbox Code Playgroud)
我想做这个:
$new_string = str_replace ('-','',$string);
Run Code Online (Sandbox Code Playgroud)
我试图用html_entity_decode解析字符串,解析字符以使用htmlspecialchars删除,但没有任何结果.
我做错了什么?
-EDIT-这是我的脚本的完整代码:
$title = 'Super Mario Galaxy 2 - Debut Trailer'; // Fetched from the DB, in the DB the character is - (minus) not –
$new_title = str_replace(' - ', '', $title);
$new_title = str_replace(" - ", '', $title);
$new_title = str_replace(html_entity_decode('–'),'',$title);
Run Code Online (Sandbox Code Playgroud)
没有人工作.基本上问题是在DB中,破折号存储为"减号"(我用减号键输入值),但由于一个奇怪的原因,输出是–
我在Wordpress上运行,而charset是UTF-8,对于DB整理来说也是如此.
在一个单独的YML文件中,我有:
flags: [<img src="/images/cms_bo/icons/english.png" alt="English"/>]
当我把它称为我的代码时,它没有被解释,所以我使用html_entity_decode.
它有效但我在我的形象之前只有一个奇怪的字符:?
<?php echo html_entity_decode($form['lang']->render()); ?>
Run Code Online (Sandbox Code Playgroud)
我的所有文件都是UTF8编码的.你对我错过了解决这个问题的想法有所了解吗?
PS:
public static function getI18nCulturesForChoice()
{
return array_combine(self::getI18nCultures(), self::getI18nCulturesFlags());
}
Run Code Online (Sandbox Code Playgroud) 我使用d3生成svg并最终得到类似于以下内容的标记:
<text class="rule" text-anchor="middle">&pound;10K</text>
Run Code Online (Sandbox Code Playgroud)
与按预期呈现的类似html相比.
<div>
£20,160 - £48,069
</div>
Run Code Online (Sandbox Code Playgroud)
是否有一个属性我需要在svg标签上设置以获得类似的编码类型?我尝试在页面中添加元标记,<meta name="content" content="application/xhtml+xml; charset=utf-8" />但这不起作用.
我正在解析一个 xml 文本,其中包含类似 \'\xc3\xa1 \xc3\xa9 \xc3\xb1\' 的字符。
\n\n我收到“在文本内容中发现无效字符。”错误,如下所示
\n\ndeclare @Xml varchar(100)\n\nset @Xml =\n\'\n<?xml version="1.0" encoding="UTF-8"?>\n<Root>\xc3\xa1</Root>\n\'\n\ndeclare @XmlId integer\n\nexecute dbo.sp_xml_preparedocument @XmlId output, @Xml\n\nselect * from openXml( @XmlId, \'/\', 2) with (\n Root varchar(10)\n)\nexecute dbo.sp_xml_removedocument @XmlId\nRun Code Online (Sandbox Code Playgroud)\n\n我收到以下错误:
\n\nThe XML parse error 0xc00ce508 occurred on line number 3, near the XML text "<Root>".\nMsg 6602, Level 16, State 2, Procedure sp_xml_preparedocument, Line 1\nThe error description is \'An invalid character was found in text content.\'.\nMsg 8179, Level 16, State 5, Line 13\nCould …Run Code Online (Sandbox Code Playgroud) 我正在尝试解码 php 中的一些特殊字符,但似乎无法找到一种方法来做到这一点。
$str = 'Thi’s i"s a’n e”xa“mple';
Run Code Online (Sandbox Code Playgroud)
这只是返回一些点。
$str = preg_replace_callback("/(&#[0-9]+;)/", function($m) {
return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
}, $str);
Run Code Online (Sandbox Code Playgroud)
其他一些测试只返回相同的字符串。
$str = html_entity_decode($str, ENT_QUOTES, 'UTF-8');
$str = htmlspecialchars_decode($str, ENT_QUOTES);
Run Code Online (Sandbox Code Playgroud)
无论如何,我一直在尝试各种组合,但真的不知道如何将其转换为 UTF-8 字符。
我期待看到的是:
Thi’s i"s a’n e”xa“mple
Run Code Online (Sandbox Code Playgroud)
实际上,如果我直接使用htmlentities它并对其进行编码,我会看到不同的字符开始。
Thi’s i"s a’n e”xa“mple
Run Code Online (Sandbox Code Playgroud)
不幸的是,我无法控制来源,而且我一直在处理这些角色。
它们是非标准的,我是否需要用我自己的查找表手动替换它们?
编辑
在此处查看此表:https : //brajeshwar.github.io/entities/
我看到我正在寻找的角色没有列出。当我测试这个表中的几个字符时,它们解码得很好。我猜php中的列表默认不完整?
我有一个名为TopicTree.ascx.cs的文件,我试图输出编码的字符串,如下所示:
string subject = reader.IsDBNull(0) ? string.Empty : reader.GetString(0);
string topic = reader.IsDBNull(1) ? string.Empty : reader.GetString(1);
subject = subject.Trim();
topic = topic.Trim();
string en_subject = Server.HtmlEncode(subject);
string en_topic = Server.HtmlEncode(topic);
string output = string.Format("<li><a href=\"searchresults.aspx?type=topics&subject={1}&topic={2}\" style=\"cursor: pointer;\">{0}</a></li>", topic, en_subject, en_topic);
Run Code Online (Sandbox Code Playgroud)
但是当我实际看到屏幕上的输出时,它没有被编码.怎么了?
我在cpp builder(或delphi)中寻找与PHP RawURLEncode(和Decode)等效的函数.
我使用以下字符串来测试:( _%_&_+_=_ _"_'_a_b_c_d_e_f_g_h_我希望只编码var值,而不是整个URL)
rawurlencode返回: _%25_%26_%2B_%3D_%20_%22_%27_a_b_c_d_e_f_g_h_
我试过没有成功:
_%25_&_+_=_%20_%22_'_a_b_c_d_e_f_g_h__%25_&_%2B_=_%20_%22_'_a_b_c_d_e_f_g_h__%_& amp;_+_=_ _& quot;_'_a_b_c_d_e_f_g_h_在"&"之后添加空格)html-encode ×10
php ×5
asp.net ×2
c# ×1
c++builder ×1
d3.js ×1
delphi ×1
encoding ×1
html ×1
security ×1
sql ×1
sql-server ×1
str-replace ×1
string ×1
svg ×1
textarea ×1
urlencode ×1
utf-8 ×1
xml ×1