Well, it's a pain in the egg. Code conversion problem: to the shape of the string as \XE9\XBB into Chinese ...
In Python we can print "\xe9\xbb\x84" directly,
In the shell we direct echo $ ' \xe9\xbb\x84 ' #echo-e ' \xe9\xbb\x84 ' is OK,
Note: You cannot directly echo $ ' \xde\xab ' |iconv-f gbk-t utf-8,
Because GBK words, \XE9\XBB is Hazel, the back of the \x84 only half word, will be an error or garbled,
UTF8 is a variable length, accounting for 1~4 bytes, Chinese characters are generally 3 bytes, such as Xe9 is 16, accounting for 8bit, that is, a byte.
But in Java, it is more than egg pain, or on the code:
01 |
Import java.io.UnsupportedEncodingException; |
03 |
public class Hex2byte { |
04 |
public static void Main (string[] args) throws Unsupportedencodingexception { |
06 |
String Source = "\\xE9\\xBB\\x84\\xE8\\x8A\\xB1\\xE6\\xA2\\xA8\\xE5\\xAE\\xB6\\xE5\\x85\\xB7\\xE8\\xBD\\xAC\\xE8\ \xae\\xa9 "; |
07 |
String sourcearr[] = Source.split ("\\\\"); Partitioning to get 16 of the data in the form of xE9 |
[ |
byte[] Bytearr = n Ew byte[sourcearr.length- 1 |