Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #548 from DragonBe/mb_substr
Browse files Browse the repository at this point in the history
GitHub Issue #546: Received a fatal because mb_substr was not found.
  • Loading branch information
gfosco committed Jan 22, 2016
2 parents bb1e618 + 822833a commit 4a57c24
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ public function validateLength($length)
*
* @param string $binaryData The binary data to convert to hex.
* @param int $length The length of the string to return.
* @throws \RuntimeException Throws an exception when multibyte support is not enabled
*
* @return string
*/
public function binToHex($binaryData, $length)
{
return mb_substr(bin2hex($binaryData), 0, $length);
if (true !== extension_loaded('mbstring')) {
throw new \RuntimeException('Multibyte support required');
}
return \mb_substr(\bin2hex($binaryData), 0, $length);
}
}

0 comments on commit 4a57c24

Please sign in to comment.