How does php determine the number of bytes occupied by a word?

Source: Internet
Author: User
How does php determine the number of bytes occupied by a word. Some new words seem to have been added in win7. The number of bytes is 4 bits. How to determine whether such a Chinese character exists in a string. For example, "abc Me @ me" & nbsp; @ represents the Chinese character of byte digit 4. When I get a single character, I take @ as two Chinese characters. How can I determine the existence of the word at the beginning? I can also use JavaScript. how can I determine the number of bytes occupied by a word in GB18030 double-character php.
Some new words seem to have been added in win7. The number of bytes is 4 bits.

How to determine whether such a Chinese character exists in a string. For example:

"Abc Me @ me"

@ Represents the Chinese character of the byte number 4. When I get a single character, I take @ as two Chinese characters.

How can I determine the existence of the word at the beginning?


------ Solution --------------------
The dual-byte part of GB 18030 adopts the GBK internal code system. On this basis, the four-byte extension is made. the encoding space of the four bytes is: 0x81 to 0xFE, 0x30 to 0x39, 0x81 to 0xFE, 0x30 to 0x39. A total of 1,587,600 code bits

That is to say, you cannot judge only one byte. if the value of the second byte is within the range of 0x30 to 0x39, it is a 4-byte Chinese character.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.