Home >Common Problem >How many characters does one space occupy?

How many characters does one space occupy?

烟雨青岚
烟雨青岚Original
2020-06-17 10:32:0422316browse

How many characters does one space occupy?

How many characters does one space occupy?

A space usually occupies 2 characters, but in some special cases it occupies 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, and full-width spaces occupy 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. For example:

1. When saving a file with ANSI encoding, half-width spaces Occupies 1 byte, full-width spaces occupy 2 bytes.

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

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

How many characters does one space occupy?

Extended information:

ASCII code: One English letter (not case sensitive) occupies one byte of space. A sequence of binary numbers, used as a digital unit in the 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

For more related knowledge, please visit PHP Chinese website! !

The above is the detailed content of How many characters does one space occupy?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to install X5 kernel?Next article:How to install X5 kernel?