1

I have UTF-8 string as bellow:

Công ty tnhh một thành viên

I visit web: https://mothereff.in/byte-counter and filter text utf-8 in textarea.

It will show "That’s 27 characters, totaling 32 bytes. #"

So, how to check byte text utf-8 equal "32 bytes" with php?

I have been using function strlen() but return result is 27, not 32.

Thank very much!

KhacNha
  • 317
  • 3
  • 13
  • Possibly [`strlen`](http://www.php.net/manual/en/function.strlen.php) and [`iconv_strlen`](http://www.php.net/manual/en/function.iconv-strlen.php). – Passerby Jan 18 '16 at 09:24
  • Possible duplicate of [Measure string size in Bytes in php](http://stackoverflow.com/questions/7568949/measure-string-size-in-bytes-in-php) – Teo Jan 18 '16 at 09:26
  • Thank very much! But, I have been using function strlen() but return result is 27, not 32. – KhacNha Jan 22 '16 at 05:54

1 Answers1

1

strlen() is what you're looking for, from the php website:

Note: strlen() returns the number of bytes rather than the number of characters in a string.

see more at php.net

Florian Humblot
  • 1,121
  • 11
  • 29