当前位置: 首页>>代码示例>>PHP>>正文


PHP HTMLPurifier_Encoder::convertToASCIIDumbLossless方法代码示例

本文整理汇总了PHP中HTMLPurifier_Encoder::convertToASCIIDumbLossless方法的典型用法代码示例。如果您正苦于以下问题:PHP HTMLPurifier_Encoder::convertToASCIIDumbLossless方法的具体用法?PHP HTMLPurifier_Encoder::convertToASCIIDumbLossless怎么用?PHP HTMLPurifier_Encoder::convertToASCIIDumbLossless使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTMLPurifier_Encoder的用法示例。


在下文中一共展示了HTMLPurifier_Encoder::convertToASCIIDumbLossless方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
 {
     static $iconv = null;
     if ($iconv === null) {
         $iconv = function_exists('iconv');
     }
     $encoding = $config->get('Core', 'Encoding');
     if ($encoding === 'utf-8') {
         return $str;
     }
     if ($config->get('Core', 'EscapeNonASCIICharacters')) {
         $str = HTMLPurifier_Encoder::convertToASCIIDumbLossless($str);
     }
     if ($iconv && !$config->get('Test', 'ForceNoIconv')) {
         return @iconv('utf-8', $encoding . '//IGNORE', $str);
     } elseif ($encoding === 'iso-8859-1') {
         return @utf8_decode($str);
     }
     trigger_error('Encoding not supported', E_USER_ERROR);
 }
开发者ID:BGCX067,项目名称:ezrpg-svn-to-git,代码行数:25,代码来源:Encoder.php

示例2: 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

示例3: test_convertToASCIIDumbLossless

 public function test_convertToASCIIDumbLossless()
 {
     // Uppercase thorn letter
     $this->assertIdentical(HTMLPurifier_Encoder::convertToASCIIDumbLossless("Þorn"), "Þorn");
     $this->assertIdentical(HTMLPurifier_Encoder::convertToASCIIDumbLossless("an"), "an");
     // test up to four bytes
     $this->assertIdentical(HTMLPurifier_Encoder::convertToASCIIDumbLossless("ó € "), "󠀠");
 }
开发者ID:ajnok,项目名称:yii2book,代码行数:8,代码来源:EncoderTest.php


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