Home  >  Article  >  Backend Development  >  C# 中 UTF8Encoding.UTF8.GetBytes(key),对应PHP中的哪个方法? 如何写

C# 中 UTF8Encoding.UTF8.GetBytes(key),对应PHP中的哪个方法? 如何写

WBOY
WBOYOriginal
2016-06-13 12:26:161320browse

C# 中 UTF8Encoding.UTF8.GetBytes(key),,对应PHP中的哪个方法? 怎么写?
C# 中 UTF8Encoding.UTF8.GetBytes(key),,对应PHP中的哪个方法?
怎么写?
------解决思路----------------------

$s = '中文abc';<br />$s = iconv('gbk', 'utf-8', $s); //不是 utf-8 时需转 utf-8<br />print_r(unpack('C*', $s));
Array<br />(<br />    [1] => 228<br />    [2] => 184<br />    [3] => 173<br />    [4] => 230<br />    [5] => 150<br />    [6] => 135<br />    [7] => 97<br />    [8] => 98<br />    [9] => 99<br />)<br /><br />
C#测试
            foreach (var c in UTF8Encoding.UTF8.GetBytes("中文abc"))<br />            {<br />                Console.WriteLine(c);<br />            }<br />

------解决思路----------------------
$s = '中文abc';<br />$s = iconv('gbk', 'utf-8', $s); //不是 utf-8 时需转 utf-8<br />print_r(unpack('C*', $s));
Array<br />(<br />    [1] => 228<br />    [2] => 184<br />    [3] => 173<br />    [4] => 230<br />    [5] => 150<br />    [6] => 135<br />    [7] => 97<br />    [8] => 98<br />    [9] => 99<br />)<br /><br />
C#测试
            foreach (var c in UTF8Encoding.UTF8.GetBytes("中文abc"))<br />            {<br />                Console.WriteLine(c);<br />            }<br />

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn