/** * Mobile用クラス実行 * * @access public * */ function execute() { $this->_container =& DIContainerFactory::getContainer(); $this->_log =& LogFactory::getLog(); $this->_filterChain =& $this->_container->getComponent("FilterChain"); $this->_actionChain =& $this->_container->getComponent("ActionChain"); $this->_db =& $this->_container->getComponent("DbObject"); $this->_session =& $this->_container->getComponent("Session"); $this->_request =& $this->_container->getComponent("Request"); $this->_modulesView =& $this->_container->getComponent("modulesView"); //$this->_mobile_obj = $this->_modulesView->getModuleByDirname("mobile"); $this->_usersView =& $this->_container->getComponent("usersView"); //mb_stringがロードされているかどうか if (!extension_loaded('mbstring') && !function_exists("mb_convert_encoding")) { include_once MAPLE_DIR . '/includes/mbstring.php'; } else { if (function_exists("mb_detect_order")) { mb_detect_order(_MB_DETECT_ORDER_VALUE); } } if (function_exists("mb_internal_encoding")) { mb_internal_encoding(INTERNAL_CODE); } if (function_exists("mb_language")) { mb_language("Japanese"); } $this->_log->trace("{$this->_classname}の前処理が実行されました", "{$this->_classname}#execute"); $this->_preFilter(); $this->_filterChain->execute(); $this->_log->trace("{$this->_classname}の後処理が実行されました", "{$this->_classname}#execute"); $this->_postFilter(); }
public function utf8parse($text, $lencode = false) { if ($lencode) { $text = utf8_encode($text); } return iconv(mb_detect_encoding($text, mb_detect_order(), true), "UTF-8", $text); }
public function gogo($email) { $mail = new PHPMailer(); $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'mail.your-server.de'; // Specify main and backup server $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = '******'; // SMTP username $mail->Password = '******'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted $mail->Port = 25; //Set the SMTP port number - 587 for authenticated TLS $mail->setFrom('*****@*****.**', 'Matchday'); //Set who the message is to be sent from $mail->addAddress($email); // Add a recipient $mail->isHTML(true); // Set email format to HTML $mail->CharSet = 'UTF-8'; $text = "Информация по инциденту 22.01.2016"; $text = iconv(mb_detect_encoding($text, mb_detect_order(), true), "UTF-8", $text); $mail->Subject = $text; $mail->Body = "Уважаемые пользователи ресурса matchday.biz! <br/><br/>\n\t\t\n\t\tБез всякого предупреждения нас отключили от хостинга. Хостер (немецкая компания hetzner.de) обнаружил перегрузку сервера, связанную с многочисленными запросами, идущими на наш сайт со стороннего адреса и отключил нас, отказавшись далее разбираться до понедельника.\n\t\tНаши специалисты диагностировали проблему и выяснили, что запросы идут с пула IP адресов ТОГО ЖЕ хостера – то есть, от него самого, что свидетельствует о том, что у хостера просто некорректно налажена работа самого хостинга.\n\t\tТехподдержка с нами отказалась работать после 18-00 пятницы немецкого времени, и сайт matchday.biz будет теперь гарантировано лежать до середины дня понедельника, 25 января.\n\t\t(желающие прочитать про очень похожий случай с этим же хостером могут сделать это тут).<br/><br/>\n\t\t\n\t\tНезависимо от того, чем закончится эта история, мы будем менять хостера, но локальная задача – включить сайт, чем мы и будем заниматься, увы, теперь только в понедельник.\n\t\tМы очень извиняемся за неудобства, причиненные этой историей, которая полностью находится вне нашего контроля.<br/><br/>\n\t\t\n\t\tПодкаст по итогам 23го тура будет записан авторами в воскресение и будет опубликован, как только сайт станет доступным.\n\t\tНи бетмен-лайв, ни фэнтэзи-лайв в23м туре провести не представляется возможным.<br/>\n\t\tВ бетмене все ставки будут засчитаны.<br/><br/>\n\t\t\n\t\tО доступности сайта мы немедленно вас проинформируем, в том числе и на сайте arsenal-blog.com.<br/><br/>\n\t\t\n\t\t\n\t\tАдминистрация matchday.biz"; if (!$mail->send()) { return false; } return true; }
function test_detect_encoding() { $this->assert_equal(MultiByte::detect_encoding(self::$test_str), mb_detect_encoding(self::$test_str)); printf("MultiByte detected encoding: %s <br>", MultiByte::detect_encoding(self::$test_str)); printf("mbstring detect order: %s <br>", implode(', ', mb_detect_order())); printf("mbstring detected encoding: %s <br>", mb_detect_encoding(self::$test_str)); }
function detect_encoding($string, $encoding_list = null, $strict = false) { if (function_exists('mb_detect_encoding')) { if ($encoding_list == null) $encoding_list = mb_detect_order(); return mb_detect_encoding($string, $encoding_list, $strict); } else { return 'UTF-8'; } }
function myalbum_callback_after_stripslashes_local($text) { if (function_exists('mb_convert_encoding') && mb_internal_encoding() != mb_http_output()) { return mb_convert_encoding($text, mb_internal_encoding(), mb_detect_order()); } else { return $text; } }
/** * @param ConsoleOutputInterface $output */ public function __construct(ConsoleOutputInterface $output) { $this->output = $output; $this->encode = extension_loaded('mbstring'); if ($this->encode && !in_array(self::TARGET_ENCODING, mb_detect_order())) { mb_detect_order(array_merge(mb_detect_order(), [self::TARGET_ENCODING])); } }
/** * 转换成utf8 * @param $text * @return string */ public static function convert2Utf8($text) { $encoding = mb_detect_encoding($text, mb_detect_order(), false); if ($encoding == "UTF-8") { $text = mb_convert_encoding($text, 'UTF-8', 'UTF-8'); } $out = iconv(mb_detect_encoding($text, mb_detect_order(), false), "UTF-8//IGNORE", $text); return $out; }
function setup_encoding() { // setup encoding mb_internal_encoding('UTF-8'); $detect_order = mb_detect_order(); $detect_order = array_merge($detect_order, explode('|', 'ASCII|ISO-8859-1|UTF-8|GBK')); $detect_order = array_unique($detect_order); mb_detect_order($detect_order); }
public function testChangeDetectOrder() { mb_detect_order(['UTF-8']); new Windows($this->output); $this->assertEquals(['UTF-8', Windows::TARGET_ENCODING], mb_detect_order()); mb_detect_order(['UTF-8', Windows::TARGET_ENCODING]); new Windows($this->output); $this->assertEquals(['UTF-8', Windows::TARGET_ENCODING], mb_detect_order()); }
/** * Fired on instantiate the module * At this point nothing from the module is loaded */ public function onInit() { mb_detect_order(self::$encoding . ", UTF-8, UTF-7, ISO-8859-1, ASCII, EUC-JP, SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP, Windows-1251, Windows-1252"); mb_internal_encoding(self::$encoding); mb_http_input(self::$encoding); mb_http_output(self::$encoding); mb_language("uni"); header("Content-Type: text/html; charset=" . self::$encoding); return $this; }
function htmlspecialchars($str, $flags = ENT_COMPAT) { global $modx; $ent_str = htmlspecialchars($str, $flags, $modx->config['modx_charset']); if (!empty($str) && empty($ent_str)) { $detect_order = implode(',', mb_detect_order()); $ent_str = mb_convert_encoding($str, $modx->config['modx_charset'], $detect_order); } return $ent_str; }
/** * Cleanup text before extracting keywords/summary * * @param null $text * * @return mixed */ private function cleanup($text = null) { // convert to UTF-8 $text = iconv(mb_detect_encoding($text, mb_detect_order(), true), "UTF-8", $text); // strip HTML tags $text = preg_replace('#<[^>]+>#', ' ', $text); // remove excess whitespace $text = preg_replace('/\\s+/', ' ', $text); return $text; }
/** * Set a Template value * * @param string $search * @param string $replace */ public function setValue($search, $replace) { if (substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') { $search = '${' . $search . '}'; } if (mb_detect_encoding($replace, mb_detect_order(), true) !== 'UTF-8') { $replace = utf8_encode($replace); } $this->_documentXML = str_replace($search, $replace, $this->_documentXML); }
function addSection($name, $title, $content, $action = 'activate') { $crumb = ''; if ($name == 'center') { $crumb = $this->getBreadCrumb(); } if (is_array($content)) { $this->sections[$name] = array('title' => $title, 'crumb' => $crumb, 'content' => $content, 'action' => $action); } else { $this->sections[$name] = array('title' => $title, 'crumb' => $crumb, 'content' => mb_detect_encoding($content, mb_detect_order(), true) == "UTF-8" ? $content : utf8_encode($content), 'action' => $action); } }
function mb_ord($string) { if (extension_loaded('mbstring') === true) { mb_language('Neutral'); mb_internal_encoding('UTF-8'); mb_detect_order(array('UTF-8', 'ISO-8859-15', 'ISO-8859-1', 'ASCII')); $result = unpack('N', mb_convert_encoding($string, 'UCS-4BE', 'UTF-8')); if (is_array($result) === true) { return $result[1]; } } return ord($string); }
function set_mbstring($lang) { // Internal content encoding = Output content charset (for skin) define('CONTENT_CHARSET', get_content_charset($lang)); // 'UTF-8', 'iso-8859-1', 'EUC-JP' or ... // Internal content encoding (for mbstring extension) define('SOURCE_ENCODING', get_source_encoding($lang)); // 'UTF-8', 'ASCII', or 'EUC-JP' mb_language(get_mb_language($lang)); mb_internal_encoding(SOURCE_ENCODING); ini_set('mbstring.http_input', 'pass'); mb_http_output('pass'); mb_detect_order('auto'); }
/** * @param null $config * * @return TestApplication */ public function __construct($config = null) { Craft::setApplication(null); clearstatcache(); // SHOW EVERYTHING error_reporting(E_ALL & ~E_STRICT); ini_set('display_errors', 1); mb_internal_encoding('UTF-8'); mb_http_input('UTF-8'); mb_http_output('UTF-8'); mb_detect_order('auto'); // No matter how much you want to delete this line... DO NOT DO IT. Craft::$enableIncludePath = false; parent::__construct($config); }
static function convert_to_utf8($value) { if (function_exists("mb_detect_encoding")) { // Rely on mb_detect_encoding()'s strict mode $src_encoding = mb_detect_encoding($value, mb_detect_order(), true); if ($src_encoding != "UTF-8") { if (function_exists("mb_convert_encoding") && $src_encoding) { $value = mb_convert_encoding($value, "UTF-8", $src_encoding); } else { $value = utf8_encode($value); } } } return $value; }
/** * Sets a new working string */ public function setString($string = '') { if (is_string($string) || is_numeric($string)) { $internal = mb_internal_encoding(); $external = mb_detect_encoding($string, mb_detect_order(), true); $this->str = iconv($external, $internal, $string); $this->str = preg_replace("/\\x{20}/u", " ", $this->str); $this->str = preg_replace("/\\x{2026}/u", "...", $this->str); $this->str = preg_replace("/[\\x{201C}\\x{201D}]/u", '"', $this->str); $this->str = preg_replace("/[\\x{2018}\\x{2019}]/u", "'", $this->str); $this->str = preg_replace("/[\\x{2013}\\x{2014}]/u", "-", $this->str); $this->str = str_replace("& ", "& ", $this->str); $this->str = trim($this->str); } return $this; }
/** * @param string $directory начальная директория сканирование файлов */ static function convert($directory) { $directory = realpath($directory); $scanned_directory = array_diff(scandir($directory), array('..', '.')); array_walk($scanned_directory, function (&$item) use($directory) { return $item = is_dir($directory . '/' . $item) ? $directory . '/' . $item : false; }); $scanned_directory = array_diff($scanned_directory, array('')); foreach ($scanned_directory as $folder) { self::convert($folder); } foreach (glob($directory . "/*." . ConverPHPFiles::$suffix) as $filename) { $data = file_get_contents($filename); $data = iconv(mb_detect_encoding($data, mb_detect_order(), true), "UTF-8", $data); file_put_contents($filename, $data); } }
function getSiteName($url) { $base_url = self::getBaseUrl($url); $html = file_get_contents($base_url); mb_detect_order("utf-8, euc-jp, sjis, jis, ascii"); $charset = strtolower(mb_detect_encoding($html)); $html = str_replace("\r", "", $html); $html = str_replace("\n", "", $html); if ($charset != "utf-8") { $html = mb_convert_encoding($html, "UTF-8", $charset); } $pattern = "<title>(.*)<\\/title>"; if (preg_match("/" . $pattern . "/i", $html, $match)) { $name = $match[1]; return $name; } else { return; } }
/** * constructor * * @param string $before 比較対象(before) 必須 * @param string $after 比較対象(after) 必須 * @param array $conf config * $conf['output'] = 結果出力先ディレクトリ(省略時、カレントディレクトリに日時情報を含んだディレクトリを作成) */ public function __construct($before, $after, $conf = array()) { mb_detect_order("ASCII,UTF-8,sjis,sjis-win,sjis-mac,euc-jp,eucjp-win,jis"); $this->fs = new filesystem(); $this->before = $this->fs->get_realpath($before) . DIRECTORY_SEPARATOR; $this->after = $this->fs->get_realpath($after) . DIRECTORY_SEPARATOR; $this->conf = $conf; if (!strlen(@$this->conf['output'])) { $this->conf['output'] = '_report_' . @date('Ymd_His'); } $this->conf['output'] = $this->fs->get_realpath($this->conf['output']) . DIRECTORY_SEPARATOR; if (!$this->validate()) { return false; } if (!$this->execute()) { return false; } return true; }
function tryConvertToUTF8($content) { $inCharset = mb_detect_encoding($content, mb_detect_order(), true); $output1 = false; if (!$inCharset) { $charsets = array('iso-8859-1', 'windows-1251', 'GB2312'); foreach ($charsets as $charset) { $output1 = iconv($charset, "UTF-8", $content); if ($output1) { break; } } } else { if ($inCharset != "UTF-8") { $output1 = iconv($inCharset, "UTF-8", $content); } } return $output1; }
function utf8EncodeRecursive(&$data) { if (is_array($data) || is_object($data)) { settype($data, 'array'); foreach ($data as &$_val) { utf8EncodeRecursive($_val); } } else { $data = strip_tags(html_entity_decode($data)); if (extension_loaded('mbstring')) { global $encodings; if (!$encodings) { $encodings = array(); foreach (explode(',', 'UTF-8,ISO-8859-1,ISO-8859-2,ISO-8859-3,ISO-8859-4,ISO-8859-5,ISO-8859-6,ISO-8859-7,ISO-8859-8,ISO-8859-9,ISO-8859-10,ISO-8859-13,ISO-8859-14,ISO-8859-15,ISO-8859-16,Windows-1252,Windows-1250,Windows-1251,Windows-1254') as $encoding) { if (in_array($encoding, mb_list_encodings())) { $encodings[] = $encoding; } } mb_detect_order(array_merge($encodings, mb_list_encodings())); } if (($encoding = mb_detect_encoding($data, null, true)) != 'UTF-8') { mb_convert_variables('UTF-8', $encoding, $data); } } elseif (!preg_match('%^(?: [\\x09\\x0A\\x0D\\x20-\\x7E] # ASCII | [\\xC2-\\xDF][\\x80-\\xBF] # non-overlong 2-byte | \\xE0[\\xA0-\\xBF][\\x80-\\xBF] # excluding overlongs | [\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2} # straight 3-byte | \\xED[\\x80-\\x9F][\\x80-\\xBF] # excluding surrogates | \\xF0[\\x90-\\xBF][\\x80-\\xBF]{2} # planes 1-3 | [\\xF1-\\xF3][\\x80-\\xBF]{3} # planes 4-15 | \\xF4[\\x80-\\x8F][\\x80-\\xBF]{2} # plane 16 )*$%xs', $data)) { if (extension_loaded('iconv')) { $data = iconv(iconv_get_encoding('internal_encoding'), 'UTF-8//IGNORE', $data); } else { $data = utf8_encode($data); } } } }
public static function init() { self::$utf8validator = (bool) extension_loaded('utf8validator'); mb_internal_encoding('UTF-8'); mb_language('uni'); mb_regex_encoding('UTF-8'); mb_detect_order(array('UTF-8', 'ISO-8859-1')); mb_substitute_character(0xfffd); MCached::connect(); $trans = MCached::get(self::TRANSKEY); if ($trans === MCached::NO_RESULT) { $win = "€" . implode('', range("‚", "Œ")) . "Ž" . implode('', range("‘", "œ")) . implode('', range("ž", "ÿ")); $win_iso = "�����"; $iso = implode('', range("€", "ÿ")); $winlen = strlen($win); $winisolen = strlen($win_iso); $isolen = strlen($iso); $trans = array('iso_to_utf8' => array(), 'win_to_utf8' => array(), 'from_utf8' => array()); for ($i = 0; $i < $isolen; $i++) { $utf8 = mb_convert_encoding($iso[$i], 'UTF-8', 'ISO-8859-1'); $trans['iso_to_utf8'][$iso[$i]] = $utf8; $trans['from_utf8'][$utf8] = $iso[$i]; } for ($i = 0; $i < $winlen; $i++) { $utf8 = mb_convert_encoding($win[$i], 'UTF-8', 'Windows-1252'); $trans['win_to_utf8'][$win[$i]] = $utf8; $trans['from_utf8'][$utf8] = $win[$i]; } for ($i = 0; $i < $winisolen; $i++) { $utf8 = mb_convert_encoding($win_iso[$i], 'UTF-8', 'ISO-8859-1'); $trans['win_to_utf8'][$win_iso[$i]] = $utf8; } MCached::add(self::TRANSKEY, $trans, 86400); } self::$trans_table = $trans; }
protected function useUtf8Encoding($argument) { return iconv(mb_detect_encoding($argument, mb_detect_order(), true), "UTF-8", $argument); }
function _wp_json_convert_string($string) { static $use_mb = null; if (is_null($use_mb)) { $use_mb = function_exists('mb_convert_encoding'); } if ($use_mb) { $encoding = mb_detect_encoding($string, mb_detect_order(), true); if ($encoding) { return mb_convert_encoding($string, 'UTF-8', $encoding); } else { return mb_convert_encoding($string, 'UTF-8', 'UTF-8'); } } else { return wp_check_invalid_utf8($string, true); } }
$CakeEvent->attach(new BcControllerEventDispatcher()); $CakeEvent->attach(new BcModelEventDispatcher()); $CakeEvent->attach(new BcViewEventDispatcher()); /** * テーマの bootstrap を実行する */ $themePath = WWW_ROOT . 'theme' . DS . Configure::read('BcSite.theme') . DS; $themeBootstrap = $themePath . 'Config' . DS . 'bootstrap.php'; if (file_exists($themeBootstrap)) { include $themeBootstrap; } } /** * 文字コードの検出順を指定 */ mb_detect_order(Configure::read('BcEncode.detectOrder')); /** * メモリー設定 */ $memoryLimit = (int) ini_get('memory_limit'); if ($memoryLimit < 32 && $memoryLimit != -1) { ini_set('memory_limit', '32M'); } /** * ロケール設定 * 指定しないと 日本語入りの basename 等が失敗する */ setlocale(LC_ALL, 'ja_JP.UTF-8'); /** * セッションスタート */
/** * Обработать файл */ public function processFile() { $file = file_get_contents($this->getAddress()); $coding = mb_detect_encoding($file, mb_detect_order(), true); if (!$coding) { $file = iconv("WINDOWS-1251", "UTF-8", $file); file_put_contents($this->getAddress(), $file); } $file = fopen($this->getAddress(), 'r'); $isFirst = true; $accidents = []; while (($data = fgetcsv($file, null, ';')) !== FALSE) { if ($isFirst) { $isFirst = false; continue; } $item = ['description' => $data[1], 'lng' => str_replace(',', '.', $data[2]), 'lat' => str_replace(',', '.', $data[3]), 'date' => \DateTime::createFromFormat('d.m.Y H:m', $data[0])->format('Y-m-d H:m:s')]; if ($item['description'] == 'ДТП БЕЗ ПОТЕРПIЛИХ') { $item['status'] = Enum::ACCIDENT_STATUS_VICTIMS; } elseif ($item['description'] == 'ДТП З ПОТЕРПIЛИМИ') { $item['status'] = Enum::ACCIDENT_STATUS_DEATHS; } else { continue; } $accidents[] = $item; } return Accident::find()->insetBatchAccidents($accidents); }