首頁 >後端開發 >php教程 >C# 中 UTF8Encoding.UTF8.GetBytes(key),,对应PHP中的哪个方法? 怎么写?

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

WBOY
WBOY原創
2016-06-20 12:46:032210瀏覽

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


回复讨论(解决方案)

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

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

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn