【发布时间】:2011-05-15 13:33:23
【问题描述】:
我在 php 中将 html_entities 用于 UTF-8。
$input = "<div> 'Testing' </div>";
echo htmlentities($input,ENT_NOQUOTES,"UTF-8");
但是,上面的编码适用于正常输入,如果我给出下面的输入并使用编码,那么我会得到空白输出。
$input = "<div>Other 'user' is working on this line. Please contribute the next line.</div>";
echo htmlentities($input,ENT_NOQUOTES,"UTF-8");
我不知道这是如何给出空白输出的。 如果我打印 $input 那么我在 $input 中得到低于值。
<div>Other user working on this line.�Please contribute the next line.</div>
htmlentities 代码中是否遗漏了什么,请大家提出建议。
谢谢,
-普拉文。
【问题讨论】:
-
你的文件是什么编码的?这些数据来自哪里? D b?如果是,数据库中的编码是什么?你的 HTML 有什么字符集?
-
我从文件中得到这个 $input。我正在逐行读取文件,然后为每一行执行上述代码。
-
文件的来源在哪里?
-
在我的本地机器中...从 UI 端我使用了上传功能,用户将通过该功能上传文件以及我正在提取的文件....
-
尝试post文件的原始上下文(包含问题的行就行了)
标签: php