Unicode character in PHP string

前端 未结 8 1747
生来不讨喜
生来不讨喜 2020-11-22 14:17

This question looks embarrassingly simple, but I haven\'t been able to find an answer.

What is the PHP equivalent to the following C# line of code?

s         


        
8条回答
  •  醉梦人生
    2020-11-22 14:39

    function unicode_to_textstring($str){
    
        $rawstr = pack('H*', $str);
    
        $newstr =  iconv('UTF-16BE', 'UTF-8', $rawstr);
        return $newstr;
    }
    

    $msg = '67714eac99c500200054006f006b0079006f002000530074006100740069006f006e003a0020';

    echo unicode_to_textstring($str);

提交回复
热议问题