當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CharsetConverter::utf8_encode方法代碼示例

本文整理匯總了PHP中TYPO3\CMS\Core\Charset\CharsetConverter::utf8_encode方法的典型用法代碼示例。如果您正苦於以下問題:PHP CharsetConverter::utf8_encode方法的具體用法?PHP CharsetConverter::utf8_encode怎麽用?PHP CharsetConverter::utf8_encode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TYPO3\CMS\Core\Charset\CharsetConverter的用法示例。


在下文中一共展示了CharsetConverter::utf8_encode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: charsetEntity2utf8

 /**
  * Convert character set and HTML entities in the value of input content array keys
  *
  * @param array Standard content array
  * @param string Charset of the input content (converted to utf-8)
  * @return void
  */
 public function charsetEntity2utf8(&$contentArr, $charset)
 {
     // Convert charset if necessary
     foreach ($contentArr as $key => $value) {
         if ((string) $contentArr[$key] !== '') {
             if ($charset !== 'utf-8') {
                 $contentArr[$key] = $this->csObj->utf8_encode($contentArr[$key], $charset);
             }
             // decode all numeric / html-entities in the string to real characters:
             $contentArr[$key] = $this->csObj->entities_to_utf8($contentArr[$key], TRUE);
         }
     }
 }
開發者ID:plan2net,項目名稱:TYPO3.CMS,代碼行數:20,代碼來源:Indexer.php

示例2: tempPageCacheContent

    /**
     * Temp cache content
     * The temporary cache will expire after a few seconds (typ. 30) or will be cleared by the rendered page, which will also clear and rewrite the cache.
     *
     * @return void
     * @todo Define visibility
     */
    public function tempPageCacheContent()
    {
        $this->tempContent = FALSE;
        if (!$this->no_cache) {
            $seconds = 30;
            $title = htmlspecialchars($this->tmpl->printTitle($this->page['title']));
            $request_uri = htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'));
            $stdMsg = '
		<strong>Page is being generated.</strong><br />
		If this message does not disappear within ' . $seconds . ' seconds, please reload.';
            $message = $this->config['config']['message_page_is_being_generated'];
            if (strcmp('', $message)) {
                // This page is always encoded as UTF-8
                $message = $this->csConvObj->utf8_encode($message, $this->renderCharset);
                $message = str_replace('###TITLE###', $title, $message);
                $message = str_replace('###REQUEST_URI###', $request_uri, $message);
            } else {
                $message = $stdMsg;
            }
            $temp_content = '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>' . $title . '</title>
		<meta http-equiv="refresh" content="10" />
	</head>
	<body style="background-color:white; font-family:Verdana,Arial,Helvetica,sans-serif; color:#cccccc; text-align:center;">' . $message . '
	</body>
</html>';
            // Fix 'nice errors' feature in modern browsers
            $padSuffix = '<!--pad-->';
            // prevent any trims
            $padSize = 768 - strlen($padSuffix) - strlen($temp_content);
            if ($padSize > 0) {
                $temp_content = str_pad($temp_content, $padSize, LF) . $padSuffix;
            }
            if (!$this->headerNoCache() && ($cachedRow = $this->getFromCache_queryRow())) {
                // We are here because between checking for cached content earlier and now some other HTTP-process managed to store something in cache AND it was not due to a shift-reload by-pass.
                // This is either the "Page is being generated" screen or it can be the final result.
                // In any case we should not begin another rendering process also, so we silently disable caching and render the page ourselves and thats it.
                // Actually $cachedRow contains content that we could show instead of rendering. Maybe we should do that to gain more performance but then we should set all the stuff done in $this->getFromCache()... For now we stick to this...
                $this->set_no_cache();
            } else {
                $this->tempContent = TRUE;
                // This flag shows that temporary content is put in the cache
                $this->setPageCacheContent($temp_content, $this->config, $GLOBALS['EXEC_TIME'] + $seconds);
            }
        }
    }
開發者ID:nicksergio,項目名稱:TYPO3v4-Core,代碼行數:57,代碼來源:TypoScriptFrontendController.php

示例3: recodeString

 /**
  * Recode string
  * Used with text strings for fonts when languages has other character sets.
  *
  * @param string The text to recode
  * @return string The recoded string. Should be UTF-8 output. MAY contain entities (eg. &#123; or &#quot; which should render as real chars).
  */
 public function recodeString($string)
 {
     // Recode string to UTF-8 from $this->nativeCharset:
     if ($this->nativeCharset && $this->nativeCharset != 'utf-8') {
         // Convert to UTF-8
         $string = $this->csConvObj->utf8_encode($string, $this->nativeCharset);
     }
     return $string;
 }
開發者ID:plan2net,項目名稱:TYPO3.CMS,代碼行數:16,代碼來源:GraphicalFunctions.php


注:本文中的TYPO3\CMS\Core\Charset\CharsetConverter::utf8_encode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。