Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在一个具有不同语言界面的网站上工作,到目前为止我使用的是英语和德语。
加载德语文本时,它会显示奇怪的字符,如下面的屏幕截图
虽然我用
header('Content-type: text/html; charset=utf-8');
以及在 html 标头中
<META http-equiv="content-type" content="text/html; charset=utf-8">
我还能做些什么来解决它?
谢谢
页面内容也需要采用 UTF-8 格式。您的内容可能是使用 MS Word 制作的,它使用 Windows 1251 编码。您需要将文档重新保存为 UTF-8。
UTF-8 不会为您转换格式。
如果这些字符串保存在文件中,则文件也必须以 UTF-8 编码。如果您从数据库中获取它们,则必须将它们存储为 UTF-8,并且您必须将连接字符集设置为 utf-8。
您还可以检查您的文本是否为 UTF-8,如果不是,请使用 utf8_encode 进行转换。