Skip to content

Commit

Permalink
coding standards fix by php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
heartsentwined committed Sep 27, 2012
1 parent 3993991 commit 9e79c4d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Heartsentwined/Utf8/Utf8.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Utf8
/**
* UTF-8 version of chr()
*
* @param int|float|string $num ('numeric')
* @param int|float|string $num ('numeric')
* @return string
*/
public static function uchr($num)
Expand All @@ -19,13 +19,14 @@ public static function uchr($num)
if($num<=0x7FF) return chr(($num>>6)+192).chr(($num&63)+128);
if($num<=0xFFFF) return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128);
if($num<=0x1FFFFF) return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128).chr(($num&63)+128);

return '';
}

/**
* UTF-8 version of ord()
*
* @param string $c
* @param string $c
* @return int
*/
public static function uord($c)
Expand All @@ -38,6 +39,7 @@ public static function uord($c)
$ord1 = ord($c{1}); if ($ord0>=192 && $ord0<=223) return ($ord0-192)*64 + ($ord1-128);
$ord2 = ord($c{2}); if ($ord0>=224 && $ord0<=239) return ($ord0-224)*4096 + ($ord1-128)*64 + ($ord2-128);
$ord3 = ord($c{3}); if ($ord0>=240 && $ord0<=247) return ($ord0-240)*262144 + ($ord1-128)*4096 + ($ord2-128)*64 + ($ord3-128);

return false;
}
}

0 comments on commit 9e79c4d

Please sign in to comment.