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


PHP eZTextCodec::useMBString方法代码示例

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


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

示例1: __construct

 function __construct($inputCharsetCode, $outputCharsetCode, $realInputCharsetCode, $realOutputCharsetCode, $inputEncoding, $outputEncoding)
 {
     $this->RequestedInputCharsetCode = $inputCharsetCode;
     $this->RequestedOutputCharsetCode = $outputCharsetCode;
     $this->InputCharsetCode = $realInputCharsetCode;
     $this->OutputCharsetCode = $realOutputCharsetCode;
     $this->InputCharacterEncodingScheme = $inputEncoding;
     $this->OutputCharacterEncodingScheme = $outputEncoding;
     $useMBStringExtension = true;
     if (isset($GLOBALS['eZTextCodecMBStringExtension'])) {
         $useMBStringExtension = $GLOBALS['eZTextCodecMBStringExtension'];
     }
     // NOTE:
     // The method eZMBStringMapper::hasMBStringExtension() has been copied and inlined here
     // Any modification must be reflected in the method
     $hasMBString = (function_exists("mb_convert_encoding") and function_exists("mb_substitute_character") and function_exists("mb_strcut") and function_exists("mb_strlen") and function_exists("mb_strpos") and function_exists("mb_strrpos") and function_exists("mb_strwidth") and function_exists("mb_substr"));
     $useMBString = ($useMBStringExtension and eZTextCodec::useMBString() and $hasMBString);
     // Map for conversion functions using encoding functions
     $encodingConvertMap = array();
     $encodingConvertInitMap = array();
     $encodingStrlenMap = array();
     $encodingStrlenMap['unicode'] = 'strlenUnicode';
     $encodingStrlenMap['utf-8'] = 'strlenUTF8';
     $encodingStrlenMap['singlebyte'] = 'strlenCodepage';
     $encodingStrlenMap['doublebyte'] = 'strlenCodepage';
     // Unicode -> other
     $encodingConvertMap['unicode']['unicode'] = 'convertNone';
     $encodingConvertMap['unicode']['utf-8'] = 'convertUnicodeToUTF8';
     $encodingConvertMap['unicode']['singlebyte'] = 'convertUnicodeToCodepage';
     $encodingConvertMap['unicode']['doublebyte'] = 'convertUnicodeToCodepage';
     $encodingConvertInitMap['unicode']['singlebyte'] = 'initializeOutputCodepage';
     $encodingConvertInitMap['unicode']['doublebyte'] = 'initializeOutputCodepage';
     // UTF8 -> other
     $encodingConvertMap['utf-8']['unicode'] = 'convertUTF8ToUnicode';
     $encodingConvertMap['utf-8']['utf-8'] = 'convertNone';
     $encodingConvertMap['utf-8']['singlebyte'] = 'convertCodepageRev';
     $encodingConvertMap['utf-8']['doublebyte'] = 'convertCodepageRev';
     $encodingConvertInitMap['utf-8']['singlebyte'] = 'initializeOutputCodepage';
     $encodingConvertInitMap['utf-8']['doublebyte'] = 'initializeOutputCodepage';
     // singlebyte -> other
     $encodingConvertMap['singlebyte']['unicode'] = 'convertCodepageToUnicode';
     $encodingConvertMap['singlebyte']['utf-8'] = 'convertCodepage';
     $encodingConvertMap['singlebyte']['singlebyte'] = 'convertCodepageMapper';
     $encodingConvertMap['singlebyte']['doublebyte'] = 'convertCodepageMapper';
     $encodingConvertInitMap['singlebyte']['unicode'] = 'initializeInputCodepage';
     $encodingConvertInitMap['singlebyte']['utf-8'] = 'initializeInputCodepage';
     $encodingConvertInitMap['singlebyte']['singlebyte'] = 'initializeCodepageMapper';
     $encodingConvertInitMap['singlebyte']['doublebyte'] = 'initializeCodepageMapper';
     // doublebyte -> other
     $encodingConvertMap['doublebyte']['unicode'] = 'convertCodepageToUnicode';
     $encodingConvertMap['doublebyte']['utf-8'] = 'convertCodepage';
     $encodingConvertMap['doublebyte']['singlebyte'] = 'convertCodepageMapper';
     $encodingConvertMap['doublebyte']['doublebyte'] = 'convertCodepageMapper';
     $encodingConvertInitMap['doublebyte']['unicode'] = 'initializeInputCodepage';
     $encodingConvertInitMap['doublebyte']['utf-8'] = 'initializeInputCodepage';
     $encodingConvertInitMap['doublebyte']['singlebyte'] = 'initializeCodepageMapper';
     $encodingConvertInitMap['doublebyte']['doublebyte'] = 'convertCodepageMapper';
     $noneConversionFunction = 'convertNone';
     $noneStrlenFunction = 'strlenNone';
     $conversionFunction = null;
     $strlenFunction = null;
     $encodingConvertInitFunction = null;
     // NOTE:
     // The method eZMBStringMapper::charsetList() hash been copied and inlined here
     // Any modification must be reflected in the method
     $mbStringCharsets =& $GLOBALS["eZMBCharsetList"];
     if ($useMBString and !is_array($mbStringCharsets)) {
         $charsetList = array("ucs-4", "ucs-4be", "ucs-4le", "ucs-2", "ucs-2be", "ucs-2le", "utf-32", "utf-32be", "utf-32le", "utf-16", "utf-16be", "utf-16le", "utf-8", "utf-7", "ascii", "euc-jp", "sjis", "eucjp-win", "sjis-win", "iso-2022-jp", "jis", "iso-8859-1", "iso-8859-2", "iso-8859-3", "iso-8859-4", "iso-8859-5", "iso-8859-6", "iso-8859-7", "iso-8859-8", "iso-8859-9", "iso-8859-10", "iso-8859-13", "iso-8859-14", "iso-8859-15", "byte2be", "byte2le", "byte4be", "byte4le", "base64", "7bit", "8bit", "utf7-imap");
         $mbStringCharsets = array();
         foreach ($charsetList as $charset) {
             $mbStringCharsets[$charset] = $charset;
         }
     }
     // Is to true if the charsets are the same and they have singlebyte encoding
     $isSinglebyteSame = false;
     $isSame = false;
     // First detect conversion type
     if ($this->InputCharsetCode == $this->OutputCharsetCode) {
         $conversionFunction = $noneConversionFunction;
         $encodingConvertInitFunction = 'initializeInputCodepage';
         $inpenc = $this->InputCharacterEncodingScheme;
         if ($inpenc == 'singlebyte') {
             $isSinglebyteSame = true;
         }
         $isSame = true;
     } else {
         if ($useMBString and isset($mbStringCharsets[$this->InputCharsetCode]) and isset($mbStringCharsets[$this->OutputCharsetCode])) {
             // NOTE:
             // The mbstringmapper object is no longer needed since all functionality is inlined
             //             $this->MBStringMapper = eZMBStringMapper::instance( $this->InputCharsetCode,
             //                                                                 $this->OutputCharsetCode );
             $conversionFunction = "convertMBString";
             $strlenFunction = "strlenMBString";
             $encodingConvertInitFunction = false;
         } else {
             $inpenc = $this->InputCharacterEncodingScheme;
             $outenc = $this->OutputCharacterEncodingScheme;
             if (isset($encodingConvertMap[$inpenc][$outenc])) {
                 $conversionFunction = $encodingConvertMap[$inpenc][$outenc];
             }
//.........这里部分代码省略.........
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:101,代码来源:eztextcodec.php


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