当前位置: 动力学知识库 > 问答 > 编程问答 >

php - UTF-8 not working nginx

问题描述:

I have a self-hosted server running nginx and PHP5-fpm on a debian (raspbian wheezy) machine.

My problem is UTF-8 special characters (åäö) aren't working. I've set <meta charset="utf-8"> in the head of the website. All files are encoded with utf-8 without BOM.

As adviced by Fleshgrinder's answer I've added charset utf-8; to nginx.conf without results.

How can I fix this?

网友答案:

Your files must be in UTF-8 as well and the HTTP header you send is more important than the meta tag.

To deliver all your content with UTF-8 encoding (HTTP header) via nginx do the following:

# /etc/nginx/nginx.conf

http {
    charset utf-8;
}

But the important part is that your files actually have to be encoded in UTF-8 for anything to work. A good editor (e.g. Notepad2, Notepad++, NetBeans IDE, Adobe Dreamweaver, …) allows you to change the encoding of your file.

分享给朋友:
您可能感兴趣的文章:
随机阅读: