Coding problems encountered in development

Source: Internet
Author: User

1, when it comes to coding, the biggest problem is garbled, why there will be garbled it?

Because the characters in the encoding and decoding, with the encoding dictionary inconsistent, resulting in garbled, common encoding has ASCII, GBK, GB2312, UTF-8, UTF-16 and so on.

2. Why do I need to encode?

Because the computer's storage is binary, that is, a. 010 This form, some Chinese, French, Russian, etc., it is necessary to encode and decode to achieve the effect.

3. What is the conversion of data types in Java?

Bit (bit), Byte (byte), char (character)

1byte = = 8bit A binary is called a bit, and a byte value range is -128~127

1char = = 2byte char is a character type with a value range of 0~65535

1char = = 16bit a char is 16 bits

1 letters = = 1byte = = 8bit

1 Kanji = = 2byte = = 16bit

Char can represent Chinese, but byte is not possible;

Char can represent an integer, can not represent a negative number, and byte can represent a value of 128 to 127;

char, byte, int for English characters, can be converted to each other;

1Kb = = 1024bit 1KB ==1024byte ==1024*8bit

4. What is the relationship between Java and Unicode?

Unicode contains two concepts, one is a character set, one is encoding, and Utf-8 is one of the encodings of Unicode.

The JVM default encoding is GBK, which means that the underlying encoding environment is GBK encoded. The string is Unicode, and when the external data is read, if no decoding is specified, it decodes the external data according to the JVM's default encoding, which decodes the external data from the JVM's default encoding. Of course, you can also specify the desired decoding method.

Unicode incorporates all the symbols of the world, each of which assigns a unique encoding, which is a large collection that can hold 100多万个 characters

5, the use of different encoding and decoding methods, can negative positive?

Of course not, because in the process of encoding and decoding, if there is no corresponding dictionary, there may be data loss situation, so there is no way to negative positive.

http://iamzhongyong.iteye.com/blog/2070106

Coding problems encountered in development (RPM)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.