Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How many characters does a space take?

Shulou Source: shulou.com Published: 2022-06-03 02:22:30 10月01日 Update

Today, I will talk to you about the number of characters in a space, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

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

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

1. When using a multi-byte character set, half-width spaces occupy 1 byte and full-width spaces occupy 2 bytes.

2. When using the Unicode character set, the half-width space occupies 2 bytes, and the full-width space occupies 2 bytes.

In a file, the number of characters occupied by spaces depends on the encoding used to save the file, such as:

1. When saving to an ANSI-encoded file, half-width spaces occupy 1 byte, and full-width spaces occupy 2 bytes.

2. When saving to a UTF8-encoded file, half-width space takes up 1 byte, and full-width space occupies 3 bytes.

3. When saving to a Unicode-encoded file, the half-width space takes up 2 bytes and the full-width space occupies 2 bytes.

Extended data:

ASCII code: an English letter (regardless of case) takes up a byte of space. A sequence of binary numbers, in a computer, as a digital unit, usually 8-bit binary numbers, 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. Three bytes of Chinese punctuation and one byte of English punctuation

Unicode coding: one English is equal to two bytes, and one Chinese (including traditional Chinese) is equal to two bytes. Two bytes of Chinese punctuation and two bytes of English punctuation

After reading the above, do you have any further understanding of how many characters a space occupies? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Byte space character code half width file full width English two punctuation Chinese content character set three binary depending on number program traditional maximum Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Docker OPPO Reno Huawei Linux