Question

Charset problem with encoding UTF-8

  • Posted July 31, 2014

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/nginx.pid;


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.

Subscribe
Share

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


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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?

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.

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