/** * test if an object exists * * @param string $identifier Identifier * * @access public * @return boolean */ function is_object($identifier) { return Array_key_exists($identifier, $this->gedcom_objects['MediaRecs']); }
/** * Loops through string to look for matches in the mapping table and replaces the * characters that has a mapping. This will convert the given string to Unicode/UTF-8. * * @param String $string String to convert to Unicode (ÙTF-8) * @return String */ public function convert($string) { $i = 0; // Initialize counter in loop $output = ''; // String to output // Go through string, fetch next character, next two characters and next three characters // to check against mapping table if mapping exist. while ($i <= Strlen($string) - 1) { $remains = Strlen($string) - $i; // Characters that remains in string $key = array(); // Initialize array // Get next, next two and next three characters (if number of remaing // characters allow it) if ($remains >= 3) { $key[3] = $this->get_key_map($string, $i, 3); } if ($remains >= 2) { $key[2] = $this->get_key_map($string, $i, 2); } if ($remains >= 1) { $key[1] = $this->get_key_map($string, $i, 1); } // Check if next three characters exist in mapping, and replace them if they do if (count($key) == 3 && Array_key_exists($key[3], $this->_mapping[3])) { $output .= Chr(Hexdec($this->_mapping[3][$key[3]])); $i += 3; // We mapped three bytes into one char, jump three forward for next loop } elseif (count($key) >= 2 && Array_key_exists($key[2], $this->_mapping[2])) { $output .= Chr(Hexdec($this->_mapping[2][$key[2]])); $i += 2; } elseif (count($key) >= 1 && Array_key_exists($key[1], $this->_mapping[1])) { $output .= Chr(Hexdec($this->_mapping[1][$key[1]])); $i++; } else { $output .= Chr(Hexdec($key[1])); $i++; } } return Utf8_encode($output); // Return the string with replacements }