header('Content-type: text/html; charset=UTF-8'); require 'I18N/UnicodeString.php'; $text = <<<EOT The Greek Alphabet<br /> α - alpha<br /> β - beta<br /> γ - gamma<br /> δ - delta<br /> ε - epsilon<br /> ζ - zeta<br /> η - eta<br /> θ - theta<br /> ι - iota<br /> κ - kappa<br /> λ - lamda<br /> μ - mu<br /> ν - nu<br /> ξ - xi<br /> ο - omikron<br /> π - pi<br /> ρ - rho<br /> ς - sigma<br /> τ - tau<br /> υ - upsilon<br /> φ - phi<br /> χ - chi<br /> ψ - psi<br /> ω - omega EOT; $u = new I18N_UnicodeString($text, 'HTML'); echo $u->toUtf8String();
/** * 10進数エンティティをつくる * * stringプロパティの文字列を10進エンティティにしてentityプロパティに格納して返します * * @return string */ public function makeDecEntity($string) { static $converterMap = null; switch ($this->_config['ua']) { case BEAR_Agent::UA_SOFTBANK: if ($converterMap === null) { $converterMap = $this->_getEmojiMap($this->_config['ua']); } $unicodes = I18N_UnicodeString::utf8ToUnicode($string); $iEighteen = new I18N_UnicodeString($unicodes, 'Unicode'); $string = $iEighteen->toUtf8String(); $string = mb_encode_numericentity($string, $converterMap, 'utf-8'); break; case BEAR_Agent::UA_DOCOMO: $emojiRegex = '[\\xF8\\xF9][\\x40-\\x7E\\x80-\\xFC]'; $string = $this->_makeEntityBySjisRegex($string, $emojiRegex); break; case BEAR_Agent::UA_EZWEB: // AUの文字範囲 // F340~F3FC // F440~F493 // F640~F6FC // F740~F7FC $emojiRegex = '[\\xF3\\xF6\\xF7][\\x40-\\xFC]|[\\xF4][\\x40-\\x93]'; $string = $this->_makeEntityBySjisRegex($string, $emojiRegex); break; default: trigger_error('Agent is not mobile.', E_USER_NOTICE); $encode = ''; break; } return $string; }
/** * Determines if two Unicode strings are equal * * @access public * @param I18N_UnicodeString $unicode The string to compare to. * @return boolean True if they are equal, false otherwise. */ function equals(&$unicode) { if ($this->length() != $unicode->length()) { // if they arn't even the same length no need to even check return false; } return $this->_unicode == $unicode->_unicode; }
/** * Converts a UTF-8 string into unicode integers. * * @param string $string A string containing Unicode values encoded in UTF-8 * * @return array The array of Unicode values. * @throws XML_Query2XML_ISO9075Mapper_Exception If a malformed UTF-8 string * was passed as argument. */ private static function _utf8ToUnicode($string) { $string = I18N_UnicodeString::utf8ToUnicode($string); if (strtolower(get_class($string)) == 'pear_error') { /* * unit tests: * testMapException1() * testMapException2() * testMapException3() */ throw new XML_Query2XML_ISO9075Mapper_Exception($string->getMessage()); } return $string; }