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


PHP SimplePie_Misc::windows_1252_to_utf8方法代码示例

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


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

示例1: change_encoding

 /**
  * Change a string from one encoding to another
  *
  * @param string $data Raw data in $input encoding
  * @param string $input Encoding of $data
  * @param string $output Encoding you want
  * @return string|boolean False if we can't convert it
  */
 public static function change_encoding($data, $input, $output)
 {
     $input = SimplePie_Misc::encoding($input);
     $output = SimplePie_Misc::encoding($output);
     // We fail to fail on non US-ASCII bytes
     if ($input === 'US-ASCII') {
         static $non_ascii_octects = '';
         if (!$non_ascii_octects) {
             for ($i = 0x80; $i <= 0xff; $i++) {
                 $non_ascii_octects .= chr($i);
             }
         }
         $data = substr($data, 0, strcspn($data, $non_ascii_octects));
     }
     // This is first, as behaviour of this is completely predictable
     if ($input === 'windows-1252' && $output === 'UTF-8') {
         return SimplePie_Misc::windows_1252_to_utf8($data);
     } elseif (function_exists('mb_convert_encoding') && ($return = SimplePie_Misc::change_encoding_mbstring($data, $input, $output))) {
         return $return;
     } elseif (function_exists('iconv') && ($return = SimplePie_Misc::change_encoding_iconv($data, $input, $output))) {
         return $return;
     } else {
         return false;
     }
 }
开发者ID:kadrim1,项目名称:metsayhistu,代码行数:33,代码来源:Misc.php

示例2: change_encoding

 function change_encoding($data, $input, $output)
 {
     $input = SimplePie_Misc::encoding($input);
     $output = SimplePie_Misc::encoding($output);
     // We fail to fail on non US-ASCII bytes
     if ($input === 'US-ASCII') {
         static $non_ascii_octects = '';
         if (!$non_ascii_octects) {
             for ($i = 0x80; $i <= 0xff; $i++) {
                 $non_ascii_octects .= chr($i);
             }
         }
         $data = substr($data, 0, strcspn($data, $non_ascii_octects));
     }
     if (function_exists('iconv') && ($return = @iconv($input, $output, $data))) {
         return $return;
     } elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($data, $output, $input))) {
         return $return;
     } elseif ($input == 'windows-1252' && $output == 'UTF-8') {
         return SimplePie_Misc::windows_1252_to_utf8($data);
     } elseif ($input == 'UTF-8' && $output == 'windows-1252') {
         return utf8_decode($data);
     }
     return $data;
 }
开发者ID:jardenberg,项目名称:SharedItems2WP,代码行数:25,代码来源:simplepie.php

示例3: change_encoding

 public static function change_encoding($data, $input, $output)
 {
     $input = SimplePie_Misc::encoding($input);
     $output = SimplePie_Misc::encoding($output);
     if ($input === 'US-ASCII') {
         static $non_ascii_octects = '';
         if (!$non_ascii_octects) {
             for ($i = 0x80; $i <= 0xff; $i++) {
                 $non_ascii_octects .= chr($i);
             }
         }
         $data = substr($data, 0, strcspn($data, $non_ascii_octects));
     }
     if ($input === 'windows-1252' && $output === 'UTF-8') {
         return SimplePie_Misc::windows_1252_to_utf8($data);
     } elseif (function_exists('mb_convert_encoding') && ($return = SimplePie_Misc::change_encoding_mbstring($data, $input, $output))) {
         return $return;
     } elseif (function_exists('iconv') && ($return = SimplePie_Misc::change_encoding_iconv($data, $input, $output))) {
         return $return;
     } else {
         return false;
     }
 }
开发者ID:himanshu12k,项目名称:ce-www,代码行数:23,代码来源:SimplePie.compiled.php

示例4: change_encoding

	function change_encoding($data, $input, $output)
	{
		$input = SimplePie_Misc::encoding($input);
		$output = SimplePie_Misc::encoding($output);

		// We fail to fail on non US-ASCII bytes
		if ($input === 'US-ASCII')
		{
			static $non_ascii_octects = '';
			if (!$non_ascii_octects)
			{
				for ($i = 0x80; $i <= 0xFF; $i++)
				{
					$non_ascii_octects .= chr($i);
				}
			}
			$data = substr($data, 0, strcspn($data, $non_ascii_octects));
		}

		// This is first, as behaviour of this is completely predictable
		if ($input === 'Windows-1252' && $output === 'UTF-8')
		{
			return SimplePie_Misc::windows_1252_to_utf8($data);
		}
		// This is second, as behaviour of this varies only with PHP version
		elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($data, $output, $input)))
		{
			return $return;
		}
		// This is last, as behaviour of this varies with OS userland and PHP version
		elseif (function_exists('iconv') && ($return = @iconv($input, $output, $data)))
		{
			return $return;
		}
		// If we can't do anything, just fail
		else
		{
			return false;
		}
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:40,代码来源:class-simplepie.php


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