strlen() and UTF-8 encoding

前端 未结 6 1585
挽巷
挽巷 2020-12-05 20:19

Assuming UTF-8 encoding, and strlen() in PHP, is it possible that this string has a length of 4?

I\'m only interested to know about strlen(), not other functions

6条回答
  •  死守一世寂寞
    2020-12-05 20:45

    Many UTF-8 characters take several bytes instead of one. That's how UTF-8 is constructed (That's how you can have so many characters in a single set).

    Try mb_strlen() instead.

提交回复
热议问题