import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -16,7 +16,7 @@
|
||||
* @package Zend_Pdf
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Binary.php 16541 2009-07-07 06:59:03Z bkarwin $
|
||||
* @version $Id: Binary.php 18985 2009-11-14 18:51:34Z alexander $
|
||||
*/
|
||||
|
||||
|
||||
@ -50,12 +50,7 @@ class Zend_Pdf_Element_String_Binary extends Zend_Pdf_Element_String
|
||||
*/
|
||||
public static function escape($inStr)
|
||||
{
|
||||
$outStr = '';
|
||||
|
||||
for ($count = 0; $count < strlen($inStr); $count++) {
|
||||
$outStr .= sprintf('%02X', ord($inStr[$count]));
|
||||
}
|
||||
return $outStr;
|
||||
return strtoupper(bin2hex($inStr));
|
||||
}
|
||||
|
||||
|
||||
@ -67,34 +62,26 @@ class Zend_Pdf_Element_String_Binary extends Zend_Pdf_Element_String
|
||||
*/
|
||||
public static function unescape($inStr)
|
||||
{
|
||||
$outStr = '';
|
||||
$nextHexCode = '';
|
||||
$chunks = array();
|
||||
$offset = 0;
|
||||
$length = 0;
|
||||
while ($offset < strlen($inStr)) {
|
||||
// Collect hexadecimal characters
|
||||
$start = $offset;
|
||||
$offset += strspn($inStr, "0123456789abcdefABCDEF", $offset);
|
||||
$chunks[] = substr($inStr, $start, $offset - $start);
|
||||
$length += strlen(end($chunks));
|
||||
|
||||
for ($count = 0; $count < strlen($inStr); $count++) {
|
||||
$nextCharCode = ord($inStr[$count]);
|
||||
|
||||
if( ($nextCharCode >= 48 /*'0'*/ &&
|
||||
$nextCharCode <= 57 /*'9'*/ ) ||
|
||||
($nextCharCode >= 97 /*'a'*/ &&
|
||||
$nextCharCode <= 102 /*'f'*/ ) ||
|
||||
($nextCharCode >= 65 /*'A'*/ &&
|
||||
$nextCharCode <= 70 /*'F'*/ ) ) {
|
||||
$nextHexCode .= $inStr[$count];
|
||||
}
|
||||
|
||||
if (strlen($nextHexCode) == 2) {
|
||||
$outStr .= chr(intval($nextHexCode, 16));
|
||||
$nextHexCode = '';
|
||||
}
|
||||
// Skip non-hexadecimal characters
|
||||
$offset += strcspn($inStr, "0123456789abcdefABCDEF", $offset);
|
||||
}
|
||||
|
||||
if ($nextHexCode != '') {
|
||||
if ($length % 2 != 0) {
|
||||
// We have odd number of digits.
|
||||
// Final digit is assumed to be '0'
|
||||
$outStr .= chr(base_convert($nextHexCode . '0', 16, 10));
|
||||
$chunks[] = '0';
|
||||
}
|
||||
|
||||
return $outStr;
|
||||
return pack('H*' , implode($chunks));
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user