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

How many bytes is a Chinese character in php?

藏色散人
Release: 2023-03-14 12:36:02
Original
2920 people have browsed it

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template