/** * 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; }
/** * 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; }