Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UTF-8 not working nginx

Tags:

php

nginx

utf-8

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?

like image 249
justanotherhobbyist Avatar asked Nov 04 '13 17:11

justanotherhobbyist


1 Answers

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.

like image 174
Fleshgrinder Avatar answered Nov 14 '22 20:11

Fleshgrinder