【问题标题】:NGINX / PHP / MySQL wrong colation in non-english caractersNGINX / PHP / MySQL 非英文字符位置错误
【发布时间】:2017-03-02 04:47:12
【问题描述】:

我正在将站点移动到新服务器,但我在新服务器中的非英语字符排序错误。在旧服务器中,我得到 "é" 在新服务器中显示 " �"

一些提示:

a) 两个站点都从同一个 MySQL 服务器读取,因此问题不在于任何 MySQL 服务器配置。静态 HTML 还会显示错误的字符,而不仅仅是来自数据库的字符串。

b) 两个站点的源代码完全相同。所以,没有什么比放一个<meta charset="UTF-8">

c) 老服务器用户 PHP 5.5.9 新的 PHP 5.6.30,Ubuntu/Nginx 都有

d) 我检查了两个 php.ini 文件,没有发现任何差异!

e) 当执行 shell 命令时curl -I *URL* I GET:

旧服务器:

HTTP/1.1 200 OK
Server: nginx
Date: Wed, 01 Mar 2017 20:00:43 GMT
Content-Type: text/html
Connection: keep-alive
Keep-Alive: timeout=60
X-Powered-By: PHP/5.5.9-1ubuntu4.20

新服务器:

HTTP/1.1 200 OK
Server: nginx/1.10.1 (Ubuntu)
Date: Wed, 01 Mar 2017 20:01:21 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive

我在curl -i 的答案中将这个Content-Type: text/html; charset=UTF-8 播种到新服务器,但我不知道它来自哪里。

任何想法在哪里找到问题?

旧服务器:http://www.pimentaingressos.com/ 新一:http://pimenta.curtipiu.net/

【问题讨论】:

标签: php html mysql nginx


【解决方案1】:

对于Mysql:

  1. 检查您的数据库字符集:http://php.net/manual/en/mysqli.get-charset.php
  2. 如果需要,使用http://php.net/manual/en/mysqli.get-charset.php 设置它
  3. 更多调试信息可能http://php.net/manual/en/mysqli.character-set-name.php


对于 PHP
  1. 检查您的 PHP 编码能力:http://php.net/manual/en/function.mb-list-encodings.php

  2. 如果使用输出缓冲区:http://php.net/manual/en/function.mb-output-handler.php

  3. 可以设置PHP内部ecnodinghttp://php.net/manual/en/function.mb-internal-encoding.php

  4. 更多关于多字节http://php.net/manual/en/ref.mbstring.php

在我的实时主机上,我只需要修复 phphmyadmin 中的排序规则即可使其正常工作。在我的开发虚拟机上,我还需要设置内部编码(PHP 列表的第 3 点)。多年来,我遇到了 1 个或多个我列出的事情,希望它能让你走上正轨。

【讨论】:

    猜你喜欢
    • 2013-09-28
    • 2011-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多