“正在展示而不是 -

jee*_*van 6 php character-encoding non-ascii-characters

’正在显示而不是-在PHP页面中

我尝试使用不同的编码类型,如:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
Run Code Online (Sandbox Code Playgroud)

和

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
Run Code Online (Sandbox Code Playgroud)

但结果是一样的.可能是什么问题呢?

输入

<strong style="color:#A8A8A8;">1</strong> - Lorem Ipsum.

结果

1 - Lorem Ipsum.

Ton*_*ark 5

确保您的 html 标头指定 utf8

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Run Code Online (Sandbox Code Playgroud)

这通常对我有用(显然,如果内容是 utf8)。

如果设置了 content-type,则不需要转换为 html 实体。


检查http://php.net/manual/en/function.mb-convert-encoding.php

<?php
     header('Content-Type: text/html; charset=utf-8');
     mb_internal_encoding('utf-8');
?>
Run Code Online (Sandbox Code Playgroud)

也许这会对你有帮助。