header('Content-type: text/html; charset=UTF-8');
require 'I18N/UnicodeString.php';
$text = <<<EOT
The Greek Alphabet<br />
&#945; - alpha<br />
&#946; - beta<br />
&#947; - gamma<br />
&#948; - delta<br />
&#949; - epsilon<br />
&#950; - zeta<br />
&#951; - eta<br />
&#952; - theta<br />
&#953; - iota<br />
&#954; - kappa<br />
&#955; - lamda<br />
&#956; - mu<br />
&#957; - nu<br />
&#958; - xi<br />
&#959; - omikron<br />
&#960; - pi<br />
&#961; - rho<br />
&#962; - sigma<br />
&#964; - tau<br />
&#965; - upsilon<br />
&#966; - phi<br />
&#967; - chi<br />
&#968; - psi<br />
&#969; - omega
EOT;
$u = new I18N_UnicodeString($text, 'HTML');
echo $u->toUtf8String();
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 /**
  * 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;
 }
Пример #4
0
 /**
  * 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;
 }