Charset problem with encoding UTF-8

July 31, 2014 5.6k views

Hi, I have a LDAP installed on Ubuntu 14.04.
My webpage is UTF-8 but I have problems when retrieving data from a form. When I submit a form that contains characters like 'ñ' or 'é' and I print the $_POST var the data I submited is corrupted because of a encoding mismatch as I undersand.

I have read a lot of tutorials and I have done everything I have found.
This is how looks my** nginx.conf** now:

user www-data;
worker_processes 4;
pid /run/;

events {
        worker_connections 768;
        # multi_accept on;

http {
        charset utf-8; <----    This should be the fix     --->

        .... other things

Should I modify de sites-enabled/default also? ( It doesn't change the result anyway )

This is the** headers,** from wget -S

  HTTP/1.1 200 OK
  Server: nginx/1.4.6 (Ubuntu)
  Date: Thu, 31 Jul 2014 16:41:36 GMT
  Content-Type: text/html; charset=utf-8
  Transfer-Encoding: chunked
  Connection: keep-alive
  X-Powered-By: PHP/5.5.9-1ubuntu4.3

The only way around for making it work was setting accept-charset="ISO-8859-1" in the form tag, but this is not a solution because doesn't work in IE and my web is a little more than a form.

I am a little bit desperate, because I don't have any more ideas for fixing it.

1 comment
  • The server is UTF-8 and the page is UTF-8, why I need ISO-8859-1 for making the form work??? Any Idea?

3 Answers

Did you try adding accept-charset="UTF-8" to the form tag?

yes, and It doesn't work. It looks like the server outputs UTF-8 but wants a ISO-8858-1 input. I don't know where to look at.

I have created another instance, using Apache this time, configuring all UTF-8 stuff from scratch and the results are the same. Could it be related to the fact that I developed the web under Windows? Should I resave all the files using linux and UTF-8?

Have another answer? Share your knowledge.