Why use multibyte string functions in PHP?

后端 未结 6 1783
情话喂你
情话喂你 2020-12-16 18:49

At the moment, I don\'t understand why it is really important to use mbstring functions in PHP when dealing with UTF-8? My locale under linux is already set

6条回答
  •  伪装坚强ぢ
    2020-12-16 19:10

    Here is my answer in plain English. A single Japanese and Chinese and Korean character take more than a single byte. Eg., a typical charactert say x is takes 1 byte in English it will take more than 1 byte in Japanese and Chinese and Korean. Now PHP's standard string functions are meant to treat a single character as 1 byte. So in case you are trying to do compare two Japanese or Chinese or Korean characters they will not work as expected. For example the length of "Hello World!" in Japanese or Chinese or Korean will have more than 12 bytes.

    Read http://www.php.net/manual/en/intro.mbstring.php

提交回复
热议问题