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


PHP HTMLPurifier_Encoder::testIconvTruncateBug方法代碼示例

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


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

示例1: convertToUTF8

 /**
  * Convert a string to UTF-8 based on configuration.
  * @param string $str The string to convert
  * @param HTMLPurifier_Config $config
  * @param HTMLPurifier_Context $context
  * @return string
  */
 public static function convertToUTF8($str, $config, $context)
 {
     $encoding = $config->get('Core.Encoding');
     if ($encoding === 'utf-8') {
         return $str;
     }
     static $iconv = null;
     if ($iconv === null) {
         $iconv = self::iconvAvailable();
     }
     if ($iconv && !$config->get('Test.ForceNoIconv')) {
         // unaffected by bugs, since UTF-8 support all characters
         $str = self::unsafeIconv($encoding, 'utf-8//IGNORE', $str);
         if ($str === false) {
             // $encoding is not a valid encoding
             trigger_error('Invalid encoding ' . $encoding, E_USER_ERROR);
             return '';
         }
         // If the string is bjorked by Shift_JIS or a similar encoding
         // that doesn't support all of ASCII, convert the naughty
         // characters to their true byte-wise ASCII/UTF-8 equivalents.
         $str = strtr($str, self::testEncodingSupportsASCII($encoding));
         return $str;
     } elseif ($encoding === 'iso-8859-1') {
         $str = utf8_encode($str);
         return $str;
     }
     $bug = HTMLPurifier_Encoder::testIconvTruncateBug();
     if ($bug == self::ICONV_OK) {
         trigger_error('Encoding not supported, please install iconv', E_USER_ERROR);
     } else {
         trigger_error('You have a buggy version of iconv, see https://bugs.php.net/bug.php?id=48147 ' . 'and http://sourceware.org/bugzilla/show_bug.cgi?id=13541', E_USER_ERROR);
     }
 }
開發者ID:dingdong2310,項目名稱:g5_theme,代碼行數:41,代碼來源:HTMLPurifier.standalone.php

示例2: calculateResult

 /**
  * Calculates the result of this requirement.
  *
  * @return string
  */
 protected function calculateResult()
 {
     if (function_exists('iconv')) {
         // See if it's the buggy version
         if (\HTMLPurifier_Encoder::testIconvTruncateBug() != \HTMLPurifier_Encoder::ICONV_OK) {
             return RequirementResult::Warning;
         } else {
             return RequirementResult::Success;
         }
     } else {
         return RequirementResult::Failed;
     }
 }
開發者ID:webremote,項目名稱:craft_boilerplate,代碼行數:18,代碼來源:Requirements.php

示例3: checkForIconv

 /**
  * Returns whether iconv is installed and not buggy.
  *
  * @return bool
  */
 public static function checkForIconv()
 {
     if (!isset(static::$_iconv)) {
         // Check if iconv is installed. Note we can't just use HTMLPurifier_Encoder::iconvAvailable() because they
         // don't consider iconv "installed" if it's there but "unusable".
         if (function_exists('iconv') && \HTMLPurifier_Encoder::testIconvTruncateBug() === \HTMLPurifier_Encoder::ICONV_OK) {
             static::$_iconv = true;
         } else {
             static::$_iconv = false;
         }
     }
     return static::$_iconv;
 }
開發者ID:ericnormannn,項目名稱:m,代碼行數:18,代碼來源:StringHelper.php

示例4: testIconvChunking

 public function testIconvChunking()
 {
     if (!HTMLPurifier_Encoder::iconvAvailable()) {
         return;
     }
     if (HTMLPurifier_Encoder::testIconvTruncateBug() !== HTMLPurifier_Encoder::ICONV_TRUNCATES) {
         return;
     }
     $this->assertIdentical(HTMLPurifier_Encoder::iconv('utf-8', 'iso-8859-1//IGNORE', "aó € b", 4), 'ab');
     $this->assertIdentical(HTMLPurifier_Encoder::iconv('utf-8', 'iso-8859-1//IGNORE', "aa中b", 4), 'aab');
     $this->assertIdentical(HTMLPurifier_Encoder::iconv('utf-8', 'iso-8859-1//IGNORE', "aaaαb", 4), 'aaab');
     $this->assertIdentical(HTMLPurifier_Encoder::iconv('utf-8', 'iso-8859-1//IGNORE', "aaaaó € b", 4), 'aaaab');
     $this->assertIdentical(HTMLPurifier_Encoder::iconv('utf-8', 'iso-8859-1//IGNORE', "aaaa中b", 4), 'aaaab');
     $this->assertIdentical(HTMLPurifier_Encoder::iconv('utf-8', 'iso-8859-1//IGNORE', "aaaaαb", 4), 'aaaab');
 }
開發者ID:ajnok,項目名稱:yii2book,代碼行數:15,代碼來源:EncoderTest.php

示例5: checkForIconv

 /**
  * Returns whether iconv is installed and not buggy.
  *
  * @return bool
  */
 public static function checkForIconv()
 {
     if (!isset(static::$_iconv)) {
         static::$_iconv = false;
         // Check if iconv is installed. Note we can't just use HTMLPurifier_Encoder::iconvAvailable() because they
         // don't consider iconv "installed" if it's there but "unusable".
         if (!function_exists('iconv')) {
             Craft::log('iconv is not installed.  Will fallback to mbstring.', LogLevel::Warning);
         } else {
             if (\HTMLPurifier_Encoder::testIconvTruncateBug() != \HTMLPurifier_Encoder::ICONV_OK) {
                 Craft::log('Buggy iconv installed.  Will fallback to mbstring.', LogLevel::Warning);
             } else {
                 static::$_iconv = true;
             }
         }
     }
     return static::$_iconv;
 }
開發者ID:kant312,項目名稱:sop,代碼行數:23,代碼來源:StringHelper.php

示例6: convertToUTF8

 public static function convertToUTF8($str, $config, $context)
 {
     $encoding = $config->get('Core.Encoding');
     if ($encoding === 'utf-8') {
         return $str;
     }
     static $iconv = null;
     if ($iconv === null) {
         $iconv = self::iconvAvailable();
     }
     if ($iconv && !$config->get('Test.ForceNoIconv')) {
         $str = self::unsafeIconv($encoding, 'utf-8//IGNORE', $str);
         if ($str === false) {
             trigger_error('Invalid encoding ' . $encoding, E_USER_ERROR);
             return '';
         }
         $str = strtr($str, self::testEncodingSupportsASCII($encoding));
         return $str;
     } elseif ($encoding === 'iso-8859-1') {
         $str = utf8_encode($str);
         return $str;
     }
     $bug = HTMLPurifier_Encoder::testIconvTruncateBug();
     if ($bug == self::ICONV_OK) {
         trigger_error('Encoding not supported, please install iconv', E_USER_ERROR);
     } else {
         trigger_error('You have a buggy version of iconv, see https://bugs.php.net/bug.php?id=48147 ' . 'and http://sourceware.org/bugzilla/show_bug.cgi?id=13541', E_USER_ERROR);
     }
 }
開發者ID:harrylongworth,項目名稱:tv-bb,代碼行數:29,代碼來源:HTMLPurifier.standalone.php


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