-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
023cc34
commit 2825548
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* Polyfill for mb_ord on PHP versions < 7.2 | ||
*/ | ||
if (!function_exists('mb_ord')) { | ||
/** | ||
* @author John Slegers | ||
* @see https://stackoverflow.com/a/24763271/1225977 | ||
* @param string $char | ||
* @param string $encoding | ||
* @return mixed | ||
*/ | ||
function mb_ord($char, $encoding = 'UTF-8') { | ||
if ($encoding === 'UCS-4BE') { | ||
list(, $ord) = (strlen($char) === 4) ? @unpack('N', $char) : @unpack('n', $char); | ||
return $ord; | ||
} else { | ||
return mb_ord(mb_convert_encoding($char, 'UCS-4BE', $encoding), 'UCS-4BE'); | ||
} | ||
} | ||
} |