0

In my PHP page, product descriptions are showing up with the infamous £ issue.

Aha! I thought - I must remember to move the entire website over to UTF-8. So I:

  • Specified in both the mysql_set_charset('utf8'); and the array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8") command. I'm migrating the website over to PDO - so still in a transitional process. The actual part of the website where the product description is saved and read both use the new PDO method.
  • Specified ini_set('default_charset', 'utf-8'); at the start of my header.php page.
  • Specified <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> in the head tag of the HTML page. I verified that there were no caching issues by checking that it appears.
  • Changed the collation of the products table to utf8_general_ci.

But the error still occurs. It even occurs on new products and when I edit the product to remove and re-add the pound sign. Is there anything I'm missing?

4

2 回答 2

2

我发现了问题。当我将它们回显到浏览器时,为了安全起见,我将它们扔到htmlentities()了字符串上。我应该抛出:

htmlentities($string, ENT_COMPAT | ENT_HTML401, "UTF-8");纠正这一点。

于 2012-08-18T22:33:37.287 回答
0

还有2件事

  • header("Content-Type: text/html; charset=utf-8");
  • 确保您的文件编码为 UTF-8(例如:使用记事本打开文件并将其保存为 UTF-8 ENCODING)
于 2012-08-18T11:09:03.230 回答