从本地服务器到远程服务器的字符集问题


Charset issue from local to remote server

我有一个字符集的问题。
在本地主机上一切都很好,但现在在远程服务器上,我看到奇怪的字符取代了其他字符,如或è。我读过这是一个字符集问题,我认为问题可能是我的php.ini(我无法编辑它)。
为了解决这个问题,我尝试了很多方法:
我设置了

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
在html

,

ini_set('default_charset', 'UTF-8');
在php

,

AddDefaultCharset utf-8 

在我的。htaccess文件,
如果我在字符串上使用utf8_encode,字母将被ã或类似的替换,如果我不做任何事情,字母将是-
我还没有找到解决这个问题的其他方法吗?

对不起,我忘了说:字符串是从另一个网站检索的file_get_contents(我使用的是Yandex API)

下面是一些代码:

$yandex = 'https://dictionary.yandex.net/api/v1/dicservice.json/lookup?key=my_api_key&lang=it-it&text=attualità';
// get json from this page
$object = json_decode(file_get_contents($yandex));
$syns_array = array();
$type = '';
// if the word exists
if (!empty($object->def) && $object->def != FALSE && $object->def != NULL) 
{
    $type = $object->def[0]->tr[0]->pos;
    $rows = $object->def[0]->tr;
    // if there're synonyms
    if (!empty($rows) && $rows != FALSE && $rows != NULL) 
    {
        foreach ($rows as $row) 
        {
            array_push($syns_array, $row->text);
            // if there're more rows with syns
            if (!empty($row->syn) && $row->syn !== FALSE && $row->syn !== NULL) 
            {
                foreach ($row->syn as $syns_obj) 
                {
                    array_push($syns_array, $syns_obj->text);
                }
            }
        }
    }
}
// I echo my synonyms from the array
foreach($syns_array as $syn) {
    echo $syn;
}

我忘了说我在这些字符串上使用了mb_strtolower。将其更换为strotolower,问题就解决了……抱歉