HTML encoding for spanish, working locally but not

2019-09-06 09:25发布

问题:

This question already has an answer here:

  • UTF-8 all the way through 15 answers

I am adding spanish as a language and I'm having problems with the encoding.

All the spanish characters work perfectly locally (this makes it harder to debug):

But on the server they look this way:

I'm pretty puzzled, you can see the beta version here.

My doctype and charset are the following:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
...

Which should be correct as far as I understand.

I am using gettext for translations.

I checked and the declared encoding of the .po file is UTF-8.

I also set bind_textdomain_codeset to UTF-8.

I'm not sure where the problem is actually relying.

回答1:

Your server is set to serve pages with this Content-Type header:

Content-Type:text/html; charset=iso-8859-1

You need to tell it to serve them as charset=utf-8 instead. You can do this in PHP too:

header('Content-Type: text/html; charset=utf-8');