• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mb_convert_encoding函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中mb_convert_encoding函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_convert_encoding函数的具体用法?PHP mb_convert_encoding怎么用?PHP mb_convert_encoding使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mb_convert_encoding函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: convert

 /**
  * Tries to convert the given HTML into a plain text format - best suited for
  * e-mail display, etc.
  *
  * <p>In particular, it tries to maintain the following features:
  * <ul>
  *   <li>Links are maintained, with the 'href' copied over
  *   <li>Information in the &lt;head&gt; is lost
  * </ul>
  *
  * @param string $html the input HTML
  * @return string the HTML converted, as best as possible, to text
  * @throws Html2TextException if the HTML could not be loaded as a {@link DOMDocument}
  */
 static function convert($html)
 {
     // replace &nbsp; with spaces
     $html = str_replace("&nbsp;", " ", $html);
     $html = str_replace(" ", " ", $html);
     if (static::isOfficeDocument($html)) {
         // remove office namespace
         $html = str_replace(array("<o:p>", "</o:p>"), "", $html);
     }
     $html = static::fixNewlines($html);
     if (mb_detect_encoding($html, "UTF-8", true)) {
         $html = mb_convert_encoding($html, "HTML-ENTITIES", "UTF-8");
     }
     $doc = new \DOMDocument();
     if (!$doc->loadHTML($html)) {
         throw new Html2TextException("Could not load HTML - badly formed?", $html);
     }
     if (static::isOfficeDocument($html)) {
         // remove office namespace
         $doc = static::fixMSEncoding($doc);
     }
     $output = static::iterateOverNode($doc);
     // remove leading and trailing spaces on each line
     $output = preg_replace("/[ \t]*\n[ \t]*/im", "\n", $output);
     $output = preg_replace("/ *\t */im", "\t", $output);
     // remove unnecessary empty lines
     $output = preg_replace("/\n\n\n*/im", "\n\n", $output);
     // remove leading and trailing whitespace
     $output = trim($output);
     return $output;
 }
开发者ID:soundasleep,项目名称:html2text,代码行数:45,代码来源:Html2Text.php


示例2: reParceCategoriesAction

 /**
  * @todo перенести в комманды
  * Контроллер для записи Категорий
  * @Secure(roles = "ROLE_ADMIN")
  * @Route("/testxmlcat", name = "testcategories")
  */
 public function reParceCategoriesAction()
 {
     $html = file_get_contents("http://www.medknigaservis.ru/ervr/medknigaservis.xml");
     $html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
     $html = iconv("windows-1251", "utf-8", $html);
     $saw = new \nokogiri($html);
     $xml = $saw->get('category')->toArray();
     #echo '<pre>';
     #print_r($xml);
     #echo '</pre>';
     #echo '<hr />';
     for ($i = 0; true; $i++) {
         if (isset($xml[$i]['#text'][0])) {
             echo '<b>' . $xml[$i]['#text'][0] . '</b><br />';
             $cat = new MarketCategory();
             $cat->setName($xml[$i]['#text'][0]);
             $cat->setOfferId($xml[$i]['id']);
             $em = $this->getDoctrine()->getManager();
             $em->persist($cat);
             $em->flush();
         } else {
             break;
         }
     }
     return $this->render('EvrikaMainBundle:Shop:main.html.twig');
 }
开发者ID:Quiss,项目名称:Evrika,代码行数:32,代码来源:MarketController.php


示例3: __construct

 /**
  * Constructor
  *
  * @param array $data the form data as name => value
  * @param string|null $suffix the optional suffix for the tmp file
  * @param string|null $suffix the optional prefix for the tmp file. If null 'php_tmpfile_' is used.
  * @param string|null $directory directory where the file should be created. Autodetected if not provided.
  * @param string|null $encoding of the data. Default is 'UTF-8'.
  */
 public function __construct($data, $suffix = null, $prefix = null, $directory = null, $encoding = 'UTF-8')
 {
     if ($directory === null) {
         $directory = self::getTempDir();
     }
     $suffix = '.fdf';
     $prefix = 'php_pdftk_fdf_';
     $this->_fileName = tempnam($directory, $prefix);
     $newName = $this->_fileName . $suffix;
     rename($this->_fileName, $newName);
     $this->_fileName = $newName;
     $fields = '';
     foreach ($data as $key => $value) {
         // Create UTF-16BE string encode as ASCII hex
         // See http://blog.tremily.us/posts/PDF_forms/
         $utf16Value = mb_convert_encoding($value, 'UTF-16BE', $encoding);
         /* Also create UTF-16BE encoded key, this allows field names containing
          * german umlauts and most likely many other "special" characters.
          * See issue #17 (https://github.com/mikehaertl/php-pdftk/issues/17)
          */
         $utf16Key = mb_convert_encoding($key, 'UTF-16BE', $encoding);
         // Escape parenthesis
         $utf16Value = strtr($utf16Value, array('(' => '\\(', ')' => '\\)'));
         $fields .= "<</T(" . chr(0xfe) . chr(0xff) . $utf16Key . ")/V(" . chr(0xfe) . chr(0xff) . $utf16Value . ")>>\n";
     }
     // Use fwrite, since file_put_contents() messes around with character encoding
     $fp = fopen($this->_fileName, 'w');
     fwrite($fp, self::FDF_HEADER);
     fwrite($fp, $fields);
     fwrite($fp, self::FDF_FOOTER);
     fclose($fp);
 }
开发者ID:aviddv1,项目名称:php-pdftk,代码行数:41,代码来源:FdfFile.php


示例4: mb_ord

function mb_ord($char)
{
    $k = mb_convert_encoding($char, 'UCS-2LE', 'UTF-8');
    $k1 = ord(substr($k, 0, 1));
    $k2 = ord(substr($k, 1, 1));
    return $k2 * 256 + $k1;
}
开发者ID:Cazzar,项目名称:Shocky,代码行数:7,代码来源:shocky.php


示例5: content_56fb07db48ec49_11926809

    function content_56fb07db48ec49_11926809($_smarty_tpl)
    {
        ?>

<!-- Block search module -->
<div id="search_block_left" class="block exclusive">
	<p class="title_block"><?php 
        echo smartyTranslate(array('s' => 'Search', 'mod' => 'blocksearch'), $_smarty_tpl);
        ?>
</p>
	<form method="get" action="<?php 
        echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getPageLink('search', true, null, null, false, null, true), ENT_QUOTES, 'UTF-8', true);
        ?>
" id="searchbox">
    	<label for="search_query_block"><?php 
        echo smartyTranslate(array('s' => 'Search products:', 'mod' => 'blocksearch'), $_smarty_tpl);
        ?>
</label>
		<p class="block_content clearfix">
			<input type="hidden" name="orderby" value="position" />
			<input type="hidden" name="controller" value="search" />
			<input type="hidden" name="orderway" value="desc" />
			<input class="search_query form-control grey" type="text" id="search_query_block" name="search_query" value="<?php 
        echo stripslashes(mb_convert_encoding(htmlspecialchars($_smarty_tpl->tpl_vars['search_query']->value, ENT_QUOTES, 'UTF-8', true), "HTML-ENTITIES", 'UTF-8'));
        ?>
" />
			<button type="submit" id="search_button" class="btn btn-default button button-small"><span><i class="icon-search"></i></span></button>
		</p>
	</form>
</div>
<!-- /Block search module --><?php 
    }
开发者ID:edilsonribeiro,项目名称:ETEC,代码行数:32,代码来源:3c8f6f2d23d9d906b43d4aa205805aeff9e19234.file.blocksearch.tpl.php


示例6: apiRequest

 private function apiRequest($apiurl, $target = 'html')
 {
     $html = null;
     $this->fetcherr = false;
     $res = $this->func->http_request($apiurl);
     if ($res['rc'] === 200) {
         if ($res['data'] && ($decd = json_decode($res['data'], true))) {
             if (is_array($decd) && isset($decd[$target])) {
                 $html = mb_convert_encoding($decd[$target], $this->cont['SOURCE_ENCODING'], 'UTF-8');
                 $ttl = 2592000;
                 // 30days
             }
         }
     }
     if (is_null($html)) {
         $this->fetcherr = true;
         if ($res['rc'] === 404) {
             // Not found
             $html = 'Target post was not found: ';
             $ttl = 3600;
         } else {
             // Network error
             $html = 'Network error, Try after 10 minute: ';
             $ttl = 60;
             $this->root->rtf['disable_render_cache'] = true;
         }
     }
     return array($html, $ttl);
 }
开发者ID:nao-pon,项目名称:xpWiki,代码行数:29,代码来源:snsref.inc.php


示例7: smarty_modifier_currency

/**
 * Formats a given decimal value to a local aware currency value
 *
 *
 * @link http://framework.zend.com/manual/de/zend.currency.options.html
 * @param float  $value Value can have a coma as a decimal separator
 * @param array  $config
 * @param string $position where the currency symbol should be displayed
 * @return float|string
 */
function smarty_modifier_currency($value, $config = null, $position = null)
{
    if (!Enlight_Application::Instance()->Bootstrap()->hasResource('Currency')) {
        return $value;
    }
    if (!empty($config) && is_string($config)) {
        $config = strtoupper($config);
        if (defined('Zend_Currency::' . $config)) {
            $config = array('display' => constant('Zend_Currency::' . $config));
        } else {
            $config = array();
        }
    } else {
        $config = array();
    }
    if (!empty($position) && is_string($position)) {
        $position = strtoupper($position);
        if (defined('Zend_Currency::' . $position)) {
            $config['position'] = constant('Zend_Currency::' . $position);
        }
    }
    $currency = Enlight_Application::Instance()->Currency();
    $value = floatval(str_replace(',', '.', $value));
    $value = $currency->toCurrency($value, $config);
    if (function_exists('mb_convert_encoding')) {
        $value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8');
    }
    $value = htmlentities($value, ENT_COMPAT, 'UTF-8', false);
    return $value;
}
开发者ID:ClaudioThomas,项目名称:shopware-4,代码行数:40,代码来源:modifier.currency.php


示例8: __construct

 public function __construct($url)
 {
     if (!preg_match('!^https?://!i', $url)) {
         $url = 'http://' . $url;
     }
     $data = Http::Request($url);
     //$enc = mb_detect_encoding($str, "UTF-8,ISO-8859-1,ASCII");
     $html = mb_convert_encoding($data, "UTF-8", "UTF-8,ISO-8859-1,ASCII");
     //$html = utf8_encode($html);
     $r = new Readability($html, $url);
     $r->init();
     if (!isset($this->metadata["title"])) {
         $this->metadata["title"] = CharacterEntities::convert(strip_tags($r->getTitle()->innerHTML));
     }
     if (!isset($this->metadata["author"])) {
         $parts = parse_url($url);
         $this->metadata["author"] = $parts["host"];
     }
     $article = $r->getContent()->innerHTML;
     if (substr($article, 0, 5) == "<body") {
         $article = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/></head>" . $article . "</html>";
     } else {
         $article = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/></head><body>" . $article . "</body></html>";
     }
     $doc = new DOMDocument();
     @$doc->loadHTML($article) or die($article);
     $doc->normalizeDocument();
     $this->images = $this->handleImages($doc, $url);
     $this->text = $doc->saveHTML();
 }
开发者ID:master3395,项目名称:CBPPlatform,代码行数:30,代码来源:OnlineArticle.php


示例9: cleanExcelData

function cleanExcelData(&$str)
{
    if (strstr($str, '"')) {
        $str = '"' . str_replace('"', '""', $str) . '"';
    }
    $str = mb_convert_encoding($str, 'UTF-16LE', 'UTF-8');
}
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:7,代码来源:file_list.php


示例10: do_iCMS

 public function do_iCMS($a = null)
 {
     if ($_GET['name']) {
         $name = $_GET['name'];
         $encode = mb_detect_encoding($name, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5"));
         if (strtoupper($encode) != 'UTF-8') {
             if (function_exists('iconv')) {
                 $name = iconv($encode, 'UTF-8//IGNORE', $name);
             } elseif (function_exists('mb_convert_encoding')) {
                 $name = mb_convert_encoding($name, 'UTF-8//IGNORE', $encode);
             }
         }
         $val = iS::escapeStr($name);
         $field = 'name';
     } elseif ($_GET['tkey']) {
         $field = 'tkey';
         $val = iS::escapeStr($_GET['tkey']);
     } elseif ($_GET['id']) {
         $field = 'id';
         $val = (int) $_GET['id'];
     } else {
         iPHP::throw404('标签请求出错', 30001);
     }
     return $this->tag($val, $field);
 }
开发者ID:sunhk25,项目名称:iCMS,代码行数:25,代码来源:tag.app.php


示例11: command_calc

 public function command_calc($user, $channel, $args)
 {
     $calc = implode(" ", $args);
     $data = file_get_contents("http://www.google.com/ig/calculator?hl=en&q=" . urlencode($calc));
     $this->bot->privmsg($channel, "0|" . $data);
     $data = mb_convert_encoding($data, 'UTF-8', mb_detect_encoding($data, 'UTF-8, ISO-8859-1', true));
     //print("1|".$data . "\n");
     $this->bot->privmsg($channel, "1|" . $data);
     $data = preg_replace("/([,{])(.*?):/", '$1"$2":', $data);
     //hack, convert js to json.
     //print("2|".$data . "\n");
     $this->bot->privmsg($channel, "2|" . $data);
     $data = stripcslashes($data);
     //print("3|".$data . "\n");
     $this->bot->privmsg($channel, "3|" . $data);
     $data = preg_replace("/<sup>(.*?)<\\/sup>/", '^$1', $data);
     //print("4|".$data . "\n");
     $this->bot->privmsg($channel, "4|" . $data);
     $data = preg_replace("/&#215;/", '\\u00d7', $data);
     //print("5|".$data . "\n");
     $this->bot->privmsg($channel, "5|" . $data);
     $data = json_decode($data, 1);
     //foreach ($data as &$node) { $node = html_entity_decode($node); }
     //print_r($data);
     $this->bot->privmsg($channel, "6|" . json_encode($data));
     $this->bot->privmsg($channel, $data["lhs"] . " = " . $data["rhs"]);
     //$this->bot->privmsg($channel, json_encode(array($data[error], $data[icc], $calc))); //DEBUG
 }
开发者ID:KimimaroTsukimiya,项目名称:SinZPHPBot,代码行数:28,代码来源:plugin.php


示例12: ConsultarCEP

function ConsultarCEP($cep)
{
    $url = 'http://www.buscacep.correios.com.br/sistemas/buscacep/resultadoBuscaCepEndereco.cfm';
    $fields = array('relaxation' => urlencode(intval($cep)), 'tipoCEP' => urlencode('ALL'), 'semelhante' => urlencode('N'));
    $fields_string = '';
    foreach ($fields as $key => $value) {
        $fields_string .= $key . '=' . $value . '&';
    }
    rtrim($fields_string, '&');
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, count($fields));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $result = utf8_decode(curl_exec($ch));
    curl_close($ch);
    $doc = new DOMDocument();
    $doc->preserveWhiteSpace = false;
    $doc->strictErrorChecking = false;
    $doc->recover = true;
    $doc->loadHTML(mb_convert_encoding($result, 'HTML-ENTITIES', 'UTF-8'));
    $xpath = new DOMXPath($doc);
    $query = "//table[@class='tmptabela']//td";
    $entries = $xpath->query($query);
    $uf = explode('/', $entries->item(2)->nodeValue)[1];
    $cidade = explode('/', $entries->item(2)->nodeValue)[0];
    $bairro = substr($entries->item(1)->nodeValue, 0, -2);
    $logradouro = substr($entries->item(0)->nodeValue, 0, -2);
    $return = array('uf' => trim($uf), 'cidade' => trim($cidade), 'bairro' => trim($bairro), 'logradouro' => trim($logradouro));
    if (!empty($return)) {
        return $return;
    } else {
        return false;
    }
}
开发者ID:samukt,项目名称:ConsultarCEPCorreios,代码行数:35,代码来源:Cep.php


示例13: GeoCode

 static function GeoCode($address, $returnBox = false)
 {
     $params =& JComponentHelper::getParams('com_webmapplus');
     $key = $params->get('gmaps_api_key', '');
     $request = "http://maps.google.com/maps/geo?q=" . urlencode($address) . "&key={$key}";
     if (function_exists("curl_version")) {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $request);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
         $page = curl_exec($ch);
         curl_close($ch);
     } elseif (ini_get('allow_url_fopen') == 1) {
         $page = file_get_contents($request);
     } else {
         echo "cURL is not installed and allow_url_fopen is false. Can not continue.";
         die;
         return false;
     }
     //Silly Google doesn't use UTF-8 Encoding
     $page = mb_convert_encoding($page, 'UTF-8', mb_detect_encoding($page, 'UTF-8, ISO-8859-1', true));
     $data = json_decode($page);
     if ($data->Status->code == "200") {
         if (!$returnBox) {
             return $data->Placemark[0]->Point->coordinates;
         } else {
             return $data->Placemark[0]->ExtendedData->LatLonBox;
         }
     } else {
         return $data->Status->code;
     }
 }
开发者ID:notWood,项目名称:webmapplus,代码行数:32,代码来源:webmapplus.php


示例14: transformAssetPaths

 /**
  * Transform asset paths based on the report
  *
  * @param $content
  * @return string
  * @throws ExtensionNotLoadedException
  */
 public function transformAssetPaths($content)
 {
     if (null === $content) {
         throw new ContentNotFoundException('No content was found to be rendered');
     }
     libxml_use_internal_errors(true);
     $doc = new \DOMDocument();
     $doc->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES'));
     $reportRouting = $this->extensionManager->findExtension('report_routing');
     if (null === $reportRouting) {
         throw new ExtensionNotLoadedException('report_routing');
     }
     /* Transform images */
     $images = $doc->getElementsByTagName('img');
     foreach ($images as $image) {
         $this->prepareAsset($image, 'src', $reportRouting);
     }
     /* Transform styles */
     $styles = $doc->getElementsByTagName('link');
     foreach ($styles as $style) {
         $this->prepareAsset($style, 'href', $reportRouting);
     }
     /* Transform scripts */
     $scripts = $doc->getElementsByTagName('script');
     foreach ($scripts as $script) {
         $this->prepareAsset($script, 'src', $reportRouting);
     }
     return $doc->saveHTML();
 }
开发者ID:angelog4,项目名称:sdk-php,代码行数:36,代码来源:RenderEngine.php


示例15: checkUtf8Encoding

 /**
  * Check for invalid UTF8 encoding and invalid byte .
  *
  * @param string $string Your string.
  *
  * @return boolean
  */
 public static function checkUtf8Encoding($string)
 {
     if (!mb_check_encoding($string, 'UTF-8') || !$string == mb_convert_encoding(mb_convert_encoding($string, 'UTF-32', 'UTF-8'), 'UTF-8', 'UTF-32')) {
         return false;
     }
     return true;
 }
开发者ID:gjerokrsteski,项目名称:pimf-framework,代码行数:14,代码来源:Character.php


示例16: getTitle

function getTitle($url)
{
    $fd = @fopen($url, 'r');
    if ($fd) {
        $html = fread($fd, 1750);
        fclose($fd);
        // Get title from title tag
        preg_match_all('/<title>(.*)<\\/title>/si', $html, $matches);
        $title = $matches[1][0];
        // Get encoding from charset attribute
        preg_match_all('/<meta.*charset=([^;"]*)">/i', $html, $matches);
        $encoding = strtoupper($matches[1][0]);
        // Convert to UTF-8 from the original encoding
        if (function_exists('mb_convert_encoding')) {
            $title = @mb_convert_encoding($title, 'UTF-8', $encoding);
        }
        if (utf8_strlen($title) > 0) {
            return $title;
        } else {
            // No title, so return filename
            $uriparts = explode('/', $url);
            $filename = end($uriparts);
            unset($uriparts);
            return $filename;
        }
    } else {
        return false;
    }
}
开发者ID:kidwellj,项目名称:scuttle,代码行数:29,代码来源:ajaxGetTitle.php


示例17: serializeValue

 public static function serializeValue($value)
 {
     if ($value === null) {
         return 'null';
     } elseif ($value === false) {
         return 'false';
     } elseif ($value === true) {
         return 'true';
     } elseif (is_float($value) && (int) $value == $value) {
         return $value . '.0';
     } elseif (is_object($value) || gettype($value) == 'object') {
         return 'Object ' . get_class($value);
     } elseif (is_resource($value)) {
         return 'Resource ' . get_resource_type($value);
     } elseif (is_array($value)) {
         return 'Array of length ' . count($value);
     } elseif (is_integer($value)) {
         return (int) $value;
     } else {
         $value = (string) $value;
         if (function_exists('mb_convert_encoding')) {
             $value = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
         }
         return $value;
     }
 }
开发者ID:dparks-seattletimes,项目名称:openworldstudios,代码行数:26,代码来源:Serializer.php


示例18: getAuthResult

function getAuthResult($postData, $cookie_file)
{
    $url = 'http://rkk.cdpf.org.cn/queryDistrictrecordCDPF.action';
    $header = array("Host: rkk.cdpf.org.cn", 'Cache-Control: max-age=0', 'Connection: keep-alive', "Content-Length: " . strlen($postData), 'Origin: http://rkk.cdpf.org.cn', 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36', 'Content-Type: application/x-www-form-urlencoded', 'Referer: http://rkk.cdpf.org.cn/content2.html', 'Accept-Encoding: gzip,deflate', 'Accept-Language: zh-CN,zh;q=0.8');
    $ch = curl_init();
    $res = curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
    $result = curl_exec($ch);
    //需要转码
    echo '<br>';
    echo mb_detect_encoding($result, array('ASCII', 'UTF-8', 'GB2312', 'GBK', 'BIG5'));
    $result = mb_convert_encoding($result, 'UTF-8', 'EUC-CN');
    echo $result;
    $pos = strpos($result, '号码一致');
    if ($pos) {
        echo '号码一致';
    } else {
        echo '不一致';
    }
    curl_close($ch);
}
开发者ID:bajian,项目名称:js-web-skills,代码行数:28,代码来源:getcookies.php


示例19: testCodeSet

 public function testCodeSet()
 {
     $gettext = Sabel_I18n_Gettext::getInstance();
     $gettext->setCodeSet("EUC-JP");
     $this->assertEquals(mb_convert_encoding("なまえ", "EUC-JP", "UTF-8"), __("name"));
     $this->assertEquals(mb_convert_encoding("じゅうしょ", "EUC-JP", "UTF-8"), __("address"));
 }
开发者ID:reoring,项目名称:sabel,代码行数:7,代码来源:Gettext.php


示例20: handleSearch

 public function handleSearch($query, $limit)
 {
     $results = array();
     foreach (array('name', 'title', 'notation', 'text') as $column) {
         $qb = $routes = $this->routeRepository->createQueryBuilder('r')->andWhere('r.published = :true')->setParameter('true', TRUE)->andWhere('r.released < :now')->setParameter('now', new \DateTime())->setParameter('query', "%{$query}%")->setMaxResults($limit);
         if ($this->websiteManager->defaultLanguage !== $this->presenter->lang) {
             $qb->leftJoin('r.translations', 'a')->andWhere('a.language = :langId')->andWhere('(a.' . $column . ' LIKE :query)')->setParameter('langId', $this->presenter->language->id);
         } else {
             $qb->andWhere('r.' . $column . ' LIKE :query');
         }
         foreach ($qb->getQuery()->getResult() as $route) {
             $text = strip_tags(html_entity_decode($route->{$column}));
             if (($len = strlen($text)) > 40) {
                 $pos = stripos($text, $query);
                 $start = $pos - 20;
                 if ($start > 0) {
                     $text = '...' . substr($text, $start);
                 }
                 if ($start + 40 < $len) {
                     $text = substr($text, 0, 40) . '...';
                 }
             }
             $results[$route->id] = array('url' => $this->presenter->link('Route', array('route' => $route)), 'name' => mb_convert_encoding($this->highlightText($route->name, $query), 'UTF-8', 'UTF-8'), 'value' => mb_convert_encoding($route->name, 'UTF-8', 'UTF-8'), 'description' => mb_convert_encoding($this->highlightText($text, $query), 'UTF-8', 'UTF-8'), 'photo' => $route->photo ? $this->template->basePath . \CmsModule\Content\Macros\MediaMacro::proccessImage($route->photo->getFileUrl(true), array('size' => 'x48')) : NULL);
         }
     }
     $this->presenter->sendResponse(new JsonResponse(array_merge($results)));
 }
开发者ID:svobodni,项目名称:web,代码行数:27,代码来源:SearchControl.php



注:本文中的mb_convert_encoding函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mb_convert_kana函数代码示例发布时间:2022-05-15
下一篇:
PHP mb_convert_case函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap