Good day.

I do a search for the site. We enter Russian characters, translate through bing and get hieroglyphs that need to be inserted into the url and go over it. Instead of rawurlencode($result) tried and urlencode($result) and just send. As a result, in the urle, the hieroglyphs are encoded like this: %EF%BB%BF%E7%9F%AD%E8%A3%A4 , and should be like this: %B6%CC%BF%E3 . For example, I took the following 短裤 : 短裤 . In Russian shorts.

How to properly and what function to prepare them for the transition?

 $value=iconv("windows-1251", "UTF-8", $_POST['text']); // То, что вы хотите перевести $appid="F0F6345C7A5063103E0693B1CBA6CE231CEF5BA7"; // AppID от Бинга, который вы получили после регистрации $from="ru"; // С какого языка будем переводить $to="zh-CHS"; // На какой $result=file_get_contents("http://api.microsofttranslator.com/V2/Ajax.svc/Translate?appId=".$appid."&from=".$from."&to=". $to."&text=".urlencode($value)); $result = str_replace("\"","",$result); echo $result; // получили иероглифы, правильные все норм. echo mb_detect_encoding($result); // говорит в кодировке UTF-8 echo mb_convert_encoding($result, 'utf-8', 'gb2312'); // Попытка переконвертировать так, выводит пустой результат $result = iconv('UTF-8', 'gb2312',$result); echo $result ; // А вот так показывает иероглифы норм echo mb_detect_encoding($result); // Но вот тут нам говорят что кодировочка то не GB2312 , а ANCII !!! echo urlencode($result); // и скорее всего из-за ANCII тут пусто. //А вот если сделать так: $result = iconv('UTF-8', 'gb2312','情侣'); // т.е передать иероглиф прямо текстом (вставьте любой иероглиф, система меняет его) echo urlencode($result); // то получим правильный урл енкоде. ПОЧЕМУ? (( 

    1 answer 1

    Resolved! Just before the hieroglyphs there was some kind of invisible info and 2 more characters were encoded before them. Replace delete them all