特殊字符与html实体显示不正确

时间:2012-03-27 10:53:02

标签: php encoding character-encoding

我在从XML文件导入的某些数据时遇到问题。不幸的是,我正在使用一些西班牙语字符,通常我只是简单地使用它们,但它不起作用。

我想要展示的例子:

PRCE PEDUCED FROM 1,395,000€

A delightful south facing villa located in Génova

应该是:

PRCE PEDUCED FROM 1,395,000€

A delightful south facing villa located in Génova  (no idea what that should be...)

有什么想法吗?

编辑: 表编码为utf8_spanish_ci,PHP目前设置为ISO-8859-1作为沟渠工作。客户端目前是UTF-8

$text = nl2br($Property->description); 
$trans_text = iconv('UTF-8', 'ISO-8859-15//TRANSLIT//IGNORE', $text);
echo $trans_text;
echo htmlentities($trans_text, ENT_QUOTES, 'ISO-8859-15');

2 个答案:

答案 0 :(得分:5)

使用http://www.i18nqa.com/debug/utf8-debug.html上的表格,我分两步完成:
âÂ,¬=> â€=> €
Gé©nova => Génova =>热那亚

我相信您可以像这样更新数据库的内容:
UPDATE tablename SET columnname = REPLACE(columnname, '€', '€');

答案 1 :(得分:0)

检查您的数据库连接字符集...您可能遇到此问题:

There are symbols like  and so on in database, what to do?