Get the App
SLTechnology News&Howtos  ›  Development  › 

How many bytes is a Chinese character in php

Shulou Source: shulou.com Published: 2022-06-02 07:00:43 09月30日 Update

Editor to share with you how many bytes a Chinese character is in php. I hope you will gain something after reading this article. Let's discuss it together.

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

This article operating environment: Windows7 system, PHP7.4 version, Dell G3 computer.

A:

For Chinese characters, if GBK and Big-5 versions are used, each Chinese character is equivalent to 2 bytes

With the UTF-8 version, each Chinese character is equivalent to 3 bytes.

Bytes are units of binary data. A byte is usually 8 bits long. However, some older computer structures use different lengths. In order to avoid confusion, words are used instead of byte in most international literature. In most computer systems, a byte is an 8-bit long unit of data, and 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, four bytes represent a word, which is the unit in which the computer can effectively process data when executing instructions. Some language descriptions require two bytes to represent a character, which is called a double-byte character set. Some processors can handle double-byte or single-byte instructions. Bytes are usually abbreviated to "B", while bits are usually abbreviated to lowercase "b", and the size of computer memory is usually represented by bytes.

After reading this article, I believe you have a certain understanding of "how many bytes is a Chinese character in php". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Tags: Byte character computer Chinese version unit data system processing Chinese character binary instruction abbreviation article UTF-8 different valid chaotic representative international Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MySQL MariaDB Linux OPPO Reno