Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Binary.php
Go to the documentation of this file.
1 <?php
24 #require_once 'Zend/Pdf/Element/String.php';
25 
26 
36 {
42  public $value;
43 
44 
51  public static function escape($inStr)
52  {
53  return strtoupper(bin2hex($inStr));
54  }
55 
56 
63  public static function unescape($inStr)
64  {
65  $chunks = array();
66  $offset = 0;
67  $length = 0;
68  while ($offset < strlen($inStr)) {
69  // Collect hexadecimal characters
70  $start = $offset;
71  $offset += strspn($inStr, "0123456789abcdefABCDEF", $offset);
72  $chunks[] = substr($inStr, $start, $offset - $start);
73  $length += strlen(end($chunks));
74 
75  // Skip non-hexadecimal characters
76  $offset += strcspn($inStr, "0123456789abcdefABCDEF", $offset);
77  }
78  if ($length % 2 != 0) {
79  // We have odd number of digits.
80  // Final digit is assumed to be '0'
81  $chunks[] = '0';
82  }
83 
84  return pack('H*' , implode($chunks));
85  }
86 
87 
94  public function toString($factory = null)
95  {
96  return '<' . self::escape((string)$this->value) . '>';
97  }
98 }
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition: block.php:9
$start
Definition: listing.phtml:18
static unescape($inStr)
Definition: Binary.php:63
toString($factory=null)
Definition: Binary.php:94