[多字节安全的htmlentities()] [英] [multibyte-safe htmlentities()]

查看:64
本文介绍了[多字节安全的htmlentities()]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我试图在保存到数据库之前逃脱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

推荐答案

text = htmlentities(
text = htmlentities(


reader-> ;价值);


但是不能用于例如日语字符。


然后我尝试了

reader->value );

but that don''t work for e.g. japanese characters.

I then tried


text = mb_convert_encoding(
text = mb_convert_encoding(


这篇关于[多字节安全的htmlentities()]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆