1. Cause of garbled characters:
Since the data is garbled character encoding format in transmitting and receiving process caused by the inconsistency.
for examples:
Input 11--> represents the binary 3 -> represents the hexadecimal 8 9 -> in hexadecimal represents 17
Here are 11 of the same input, but because the band is not the same, the value represented is not the same.
Similarly, a string of bytes is encoded in the underlying code, due to the different encoding formats, such as encoded in UTF-8 encoding format to iso8859-1 encoding format can not be resolved, so that the string is not unfolded the original string.
2. Character garbled solution
2.1 garbled first encoding, decoding is performed
User.getUserCount userCount = String (); // garbled string format conversion according to the error code to the original code sequence of bytes byte [] BS = userCount.getBytes ( "iso889-1"); // original word section code sequence using the correct encoding format for encoding, converted to the correct character userCount = new String (bs, " utf-8");
2.2