Home  >  Article  >  Backend Development  >  How many bytes is a Chinese character in php?

How many bytes is a Chinese character in php?

藏色散人
藏色散人Original
2021-12-13 10:29:562887browse

For Chinese characters in php, if the GBK and Big-5 versions are used, each Chinese character is equivalent to 2 bytes; if the UTF-8 version is used, each Chinese character is equivalent to 3 bytes .

How many bytes is a Chinese character in php?

#The operating environment of this article: Windows 7 system, PHP version 7.4, Dell G3 computer.

How many bytes is a Chinese character in php? How many bytes does a Chinese character occupy in php?

Answer:

For Chinese characters, if you use the GBK and Big-5 versions, each Chinese character is equivalent to 2 bytes;

If you use the UTF-8 version , each Chinese character is equivalent to 3 bytes.

Byte is the unit of binary data. A byte is usually 8 bits long. However, some older computer architectures use different lengths. To avoid confusion, in most international literature the word byte is used instead of byte. In most computer systems, a byte is an 8-bit unit of data. Most computers use a byte to represent a character, number, or other character. A byte can also represent a series of binary bits. In some computer systems, 4 bytes represent a word, which is the unit of data that the computer can efficiently process when executing instructions. Some language descriptions require 2 bytes to represent a character, which is called a double-byte character set. Some processors are capable of handling double-byte or single-byte instructions. Bytes are often abbreviated as "B" and bits are often abbreviated as lowercase "b". The size of computer memory is usually expressed in bytes.

Recommended study: "PHP Video Tutorial"

The above is the detailed content of How many bytes is a Chinese character in php?. 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