src/CFPropertyList/CFBinaryPropertyList.php
public function stringToBinary($val)
    {
        $saved_object_count = -1;

        if (!isset($this->uniqueTable[$val])) {
            $saved_object_count = $this->writtenObjectCount++;
            $this->uniqueTable[$val] = $saved_object_count;
            $utf16 = false;

            for ($i=0; $i<strlen($val); ++$i) {
                if (ord($val{$i}) >= 128) {
                    $utf16 = true;
                    break;
                }
            }

            if ($utf16) {
                $bdata = self::typeBytes("6", mb_strlen($val, 'UTF-8')); // 6 is 0110, unicode string (utf16be)
                $val = self::convertCharset($val, 'UTF-8', 'UTF-16BE');
                $this->objectTable[$saved_object_count] = $bdata.$val;
            } else {
                $bdata = self::typeBytes("5", strlen($val)); // 5 is 0101 which is an ASCII string (seems to be ASCII encoded)
                $this->objectTable[$saved_object_count] = $bdata.$val;
            }
        } else {
            $saved_object_count = $this->uniqueTable[$val];
        }

        return $saved_object_count;
    }
public function stringToBinary($val)
    {
        $saved_object_count = -1;

        if (!isset($this->uniqueTable[$val])) {
            $saved_object_count = $this->writtenObjectCount++;
            $this->uniqueTable[$val] = $saved_object_count;
            $utf16 = false;

            for ($i=0; $i<strlen($val); ++$i) {
                if (ord($val{$i}) >= 128) {
                    $utf16 = true;
                    break;
                }
            }

            if ($utf16) {
                $bdata = self::typeBytes("6", mb_strlen($val, 'UTF-8')); // 6 is 0110, unicode string (utf16be)
                $val = self::convertCharset($val, 'UTF-8', 'UTF-16BE');
                $this->objectTable[$saved_object_count] = $bdata.$val;
            } else {
                $bdata = self::typeBytes("5", strlen($val)); // 5 is 0101 which is an ASCII string (seems to be ASCII encoded)
                $this->objectTable[$saved_object_count] = $bdata.$val;
            }
        } else {
            $saved_object_count = $this->uniqueTable[$val];
        }

        return $saved_object_count;
    }
public function stringToBinary ( $ val ) { $ saved_object_count = - 1 ; if ( ! isset ( $ this -> uniqueTable [ $ val ] ) ) { $ saved_object_count = $ this -> writtenObjectCount ++ ; $ this -> uniqueTable [ $ val ] = $ saved_object_count ; $ utf16 = false ; for ( $ i = 0 ; $ i < strlen ( $ val ) ; ++ $ i ) { if ( ord ( $ val { $ i } ) >= 128 ) { $ utf16 = true ; break ; } } if ( $ utf16 ) { $ bdata = self :: typeBytes ( "6" , mb_strlen ( $ val , 'UTF-8' ) ) ; // 6 is 0110, unicode string (utf16be) $ val = self :: convertCharset ( $ val , 'UTF-8' , 'UTF-16BE' ) ; $ this -> objectTable [ $ saved_object_count ] = $ bdata . $ val ; } else { $ bdata = self :: typeBytes ( "5" , strlen ( $ val ) ) ; // 5 is 0101 which is an ASCII string (seems to be ASCII encoded) $ this -> objectTable [ $ saved_object_count ] = $ bdata . $ val ; } } else { $ saved_object_count = $ this -> uniqueTable [ $ val ] ; } return $ saved_object_count ; }
Uniques and transforms a string value to binary format and adds it to the object table
@param string $val The string value
@return integer The position in the object table
Uniques and transforms a string value to binary format and adds it to the object table