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


PHP HTMLPurifier_Encoder::testEncodingSupportsASCII方法代碼示例

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


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

示例1: convertFromUTF8

 /**
  * Converts a string from UTF-8 based on configuration.
  * @note Currently, this is a lossy conversion, with unexpressable
  *       characters being omitted.
  */
 public static function convertFromUTF8($str, $config, $context)
 {
     $encoding = $config->get('Core.Encoding');
     if ($encoding === 'utf-8') {
         return $str;
     }
     static $iconv = null;
     if ($iconv === null) {
         $iconv = function_exists('iconv');
     }
     if ($escape = $config->get('Core.EscapeNonASCIICharacters')) {
         $str = HTMLPurifier_Encoder::convertToASCIIDumbLossless($str);
     }
     set_error_handler(array('HTMLPurifier_Encoder', 'muteErrorHandler'));
     if ($iconv && !$config->get('Test.ForceNoIconv')) {
         // Undo our previous fix in convertToUTF8, otherwise iconv will barf
         $ascii_fix = HTMLPurifier_Encoder::testEncodingSupportsASCII($encoding);
         if (!$escape && !empty($ascii_fix)) {
             $clear_fix = array();
             foreach ($ascii_fix as $utf8 => $native) {
                 $clear_fix[$utf8] = '';
             }
             $str = strtr($str, $clear_fix);
         }
         $str = strtr($str, array_flip($ascii_fix));
         // Normal stuff
         $str = iconv('utf-8', $encoding . '//IGNORE', $str);
         restore_error_handler();
         return $str;
     } elseif ($encoding === 'iso-8859-1') {
         $str = utf8_decode($str);
         restore_error_handler();
         return $str;
     }
     trigger_error('Encoding not supported', E_USER_ERROR);
 }
開發者ID:uskumar33,項目名稱:DeltaONE,代碼行數:41,代碼來源:Encoder.php

示例2: assertASCIISupportCheck

 public function assertASCIISupportCheck($enc, $ret)
 {
     $test = HTMLPurifier_Encoder::testEncodingSupportsASCII($enc, true);
     if ($test === false) {
         return;
     }
     $this->assertIdentical(HTMLPurifier_Encoder::testEncodingSupportsASCII($enc), $ret);
     $this->assertIdentical(HTMLPurifier_Encoder::testEncodingSupportsASCII($enc, true), $ret);
 }
開發者ID:ajnok,項目名稱:yii2book,代碼行數:9,代碼來源:EncoderTest.php


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