Révision | c1e6d703b51ea489d6ce24efbc67767ca88f1723 (tree) |
---|---|
l'heure | 2013-01-19 09:08:43 |
Auteur | miko2u <miko@cafe...> |
Commiter | miko2u |
for PHP5.4 (internal hex2bin)
@@ -349,13 +349,17 @@ function decode($str) | ||
349 | 349 | return hex2bin($str); |
350 | 350 | } |
351 | 351 | |
352 | +// hex2bin -- Converts the hex representation of data to binary | |
353 | +// (PHP 5.4.0) | |
352 | 354 | // Inversion of bin2hex() |
353 | -function hex2bin($hex_string) | |
354 | -{ | |
355 | - // preg_match : Avoid warning : pack(): Type H: illegal hex digit ... | |
356 | - // (string) : Always treat as string (not int etc). See BugTrack2/31 | |
357 | - return preg_match('/^[0-9a-f]+$/i', $hex_string) ? | |
358 | - pack('H*', (string)$hex_string) : $hex_string; | |
355 | +if (! function_exists('hex2bin')) { | |
356 | + function hex2bin($hex_string) | |
357 | + { | |
358 | + // preg_match : Avoid warning : pack(): Type H: illegal hex digit ... | |
359 | + // (string) : Always treat as string (not int etc). See BugTrack2/31 | |
360 | + return preg_match('/^[0-9a-f]+$/i', $hex_string) ? | |
361 | + pack('H*', (string)$hex_string) : $hex_string; | |
362 | + } | |
359 | 363 | } |
360 | 364 | |
361 | 365 | // Remove [[ ]] (brackets) |