Joke Collection Website - Public benefit messages - How many characters does a space take?

How many characters does a space take?

A space usually takes up 2 characters, but in some special cases it takes up 3 characters.

In the program, the number of characters occupied by spaces depends on the character set used by the program, such as:

1. When using multi-byte character sets, half-width spaces occupy 1 byte. , a full-width space takes up 2 bytes.

2. When using the Unicode character set, half-width spaces occupy 2 bytes, and full-width spaces occupy 2 bytes.

In the file, the number of characters occupied by spaces depends on the encoding used when saving the file, such as:

1. When saving files in ANSI encoding, half-width spaces occupy 1 character. section, full-width spaces occupy 2 bytes.

2. When saving as a UTF8-encoded file, half-width spaces occupy 1 byte, and full-width spaces occupy 3 bytes.

3. When saving as a Unicode-encoded file, half-width spaces occupy 2 bytes, and full-width spaces occupy 2 bytes.

Extended information

ASCII code: One English letter (regardless of upper and lower case) occupies one byte of space. A binary number sequence, used as a digital unit in a computer, is generally an 8-bit binary number, converted to decimal. The minimum value is -128 and the maximum value is 127. For example, an ASCII code is a byte.

UTF-8 encoding: One English character is equal to one byte, and one Chinese character (including traditional Chinese) is equal to three bytes. Chinese punctuation occupies three bytes, and English punctuation occupies one byte

Unicode encoding: one English is equal to two bytes, and one Chinese (including traditional Chinese) is equal to two bytes. Chinese punctuation occupies two bytes, and English punctuation occupies two bytes

Baidu Encyclopedia - Characters