Wrong encoding with PHP

点点圈 提交于 2019-12-10 18:23:58

问题


Production server (This is the correct behaviour)

>>> $str = "àáâãäåæçèéêëìíîïðñòóôõöøùúûüý";
=> "àáâãäåæçèéêëìíîïðñòóôõöøùúûüý"
>>> strtoupper($str);
=> "àáâãäåæçèéêëìíîïðñòóôõöøùúûüý"
>>> mb_strtoupper($str);
=> "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝ"

New local environment

>>> $str = "àáâãäåæçèéêëìíîïðñòóôõöøùúûüý";
=> "àáâãäåæçèéêëìíîïðñòóôõöøùúûüý</string>"
>>> strtoupper($str);
=> "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝ</string>"
>>> mb_strtoupper($str);
=> "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝ</string>"

I can't find anything on the internet regarding this </string> at the end of the variable.

It also fails with iconv function

Production server

>>> iconv('UTF-8', 'ASCII//TRANSLIT', 'áè');
=> "ae"

New local environment

>>> iconv('UTF-8', 'ASCII//TRANSLIT', 'áè');
=> "'a`e" 

I followed the instructions regarding PHP found in this answer but no luck, I ignored MySQL since I'm not using it, I also ignored the Apache one since I have Nginx.

I started to think it's because mbstring extension but can't find anything related with that.

EDIT: It's not a duplicate of this because it's not an issue with MySQL and I already tried the solutions exposed there. It's not a matter of get an alternative for iconv but to fix the environment to do the same as Production.

来源:https://stackoverflow.com/questions/46730617/wrong-encoding-with-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!