How to convert Chinese to bytes, for example, "Guangdong" to byte [] = {[-27,-71,-65,-28,-72,-100]}
To use a ready-made function, you still need to compile a function a little.
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. if you need a negative number, it will be reduced by 256 for each item.
Seek for direct php code for temporary use, and study it carefully later
$ S = "Guangdong"; $ s = iconv ('gbk', 'utf-8', $ s); $ r = array_map ('ord ', str_split ($ s); print_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 ); print_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 ); print_r ($ r );
Array( [1] => -27 [2] => -71 [3] => -65 [4] => -28 [5] => -72 [6] => -100)