Working with hieroglyphs in PHP (gb2312)

Good afternoon.

I’m doing a search for the site. We enter Russian characters, translate through bing and get hieroglyphs that need to be inserted into the URL and follow it. Instead of rawurlencode($result)I also tried urlencode($result)and just send. As a result, hieroglyphs in the url are encoded like this: %EF%BB%BF%E7%9F%AD%E8%A3%A4, and they should be like this: %B6%CC%BF%E3. I took the hieroglyphs themselves for example: 短裤. Shorts in Russian.

What is the right way 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); //      .  ? ((

Answer 1, authority 100%

It’s decided!
Just before the hieroglyphs there was some kind of invisible info and 2 more characters were encoded in front of them. Replay delete them and all

Leave a reply

Please enter your comment!
Please enter your name here