问题描述
我试图在保存到数据库之前逃脱html。
我试过
$ text = htmlentities($ reader-> value);
但是不能用于例如日语字符。
然后我尝试了
$ text = mb_convert_encoding($ text,''HTML-ENTITIES'',''UTF- 16'');
因为文本文件是用UTF-16编码的。
但是特别是没有用。如果我指定''UTF-8''
文本看起来正常,但没有任何内容被转义? html标签仍然是
显示为标签。
有人可以建议做什么吗?
谢谢
-Thorsten
Hi,
I''m trying to escape html before its saved in a database.
I tried
$text = htmlentities( $reader->value );
but that don''t work for e.g. japanese characters.
I then tried
$text = mb_convert_encoding( $text, ''HTML-ENTITIES'', ''UTF-16'' );
because the text-file is encode in UTF-16.
But that in particular doesn''t work. If I specify ''UTF-8''
the text looks normal, but nothing is escaped s? html tags still
appears as tags.
can anyone suggest what to do?
Thanks
-Thorsten
推荐答案
这篇关于[多字节安全的htmlentities()]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!