For example "Guangdong" converted into byte[]={[-27, 71,-65,-28,-72,-100]}
With a ready-made function or a little bit of a function
Reply to discussion (solution)
var B = Encoding.UTF8.GetBytes ("Guangdong"); Console.WriteLine (String. Join (",", b));
229,185,191,228,184,156
Byte is an unsigned integer, minus 256 for each item if you must have a negative number.
Ask for a direct PHP code, temporary use, and then carefully study
$s = "Guangdong"; $s = iconv (' GBK ', ' utf-8 ', $s); $r = Array_map (' Ord ', Str_split ($s));p rint_r ($r);
Array ( [0] = 229 [1] = 185 [2] = 191 [3] = = 228 [4] = = 184 [5] = 156)
Or
$s = "Guangdong"; $s = iconv (' GBK ', ' utf-8 ', $s); $r = Unpack (' c* ', $s);p rint_r ($r);
Array ( [1] = 229 [2] = 185 [3] = 191 [4] = = 228 [5] = = 184 [6] = 156)
Or
$s = "Guangdong"; $s = iconv (' GBK ', ' utf-8 ', $s); $r = Unpack (' c* ', $s);p rint_r ($r);
Array ( [1] = -27 [2] = -71 [3] = -65 [4] = -28 [5] = -72 [6] = 100)