LdapTools\Utilities\MBString::chr PHP Method

chr() public static method

Get the character for a specific integer value.
public static chr ( $int ) : string
$int
return string
    public static function chr($int)
    {
        if (self::isMbstringLoaded()) {
            return mb_convert_encoding(pack('n', $int), 'UTF-8', 'UTF-16BE');
        }
        return chr($int);
    }

Usage Example

Example #1
0
 /**
  * Given the TSPropertyArray binary data, extract out all of the TSProperty values.
  *
  * @param string $tsPropArray
  * @return array
  */
 protected function decode($tsPropArray)
 {
     $tsPropArray = bin2hex($tsPropArray);
     // The signature is a 2-byte unicode character at the front
     $this->signature = MBString::chr(hexdec(substr($tsPropArray, 0, 2)));
     // The property count is a 2-byte unsigned integer indicating the number of elements for the tsPropertyArray
     // It starts at position 2. The actual variable data begins at position 4.
     $length = $this->addTSPropData(substr($tsPropArray, 4), hexdec(substr($tsPropArray, 2, 2)));
     // Reserved data length + (count and sig length == 4) + the added lengths of the TSPropertyArray
     // This saves anything after that variable TSPropertyArray data, so as to not squash anything stored there
     if (strlen($tsPropArray) > 4 + $length) {
         $this->postBinary = hex2bin(substr($tsPropArray, 4 + $length));
     }
 }