Created
February 18, 2012 09:55
-
-
Save mazhar266/bd21f7b29730aeff86d1 to your computer and use it in GitHub Desktop.
strlen of utf8 unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function utf8_strlen ($s) | |
{ | |
$c = strlen($s); $l = 0; | |
for ($i = 0; $i < $c; ++$i) | |
if ((ord($s[$i]) & 0xC0) != 0x80) | |
++$l; | |
return $l; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment