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


PHP MultiByte::detect_encoding方法代码示例

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


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

示例1: test_substr

 function test_substr()
 {
     printf("Test string: %s <br>", self::$test_str);
     printf("Habari encoding: %s <br>", MultiByte::hab_encoding());
     printf("mb_internal_encoding: %s <br>", mb_internal_encoding());
     printf("MultiByte detected encoding of test string: %s <br>", MultiByte::detect_encoding(self::$test_str));
     printf("mbstring detected encoding of test string: %s <br>", mb_detect_encoding(self::$test_str));
     $this->assert_equal(MultiByte::substr(self::$test_str, 1, 3), mb_substr(self::$test_str, 1, 3));
     $this->assert_equal(MultiByte::substr(self::$test_str, 1, 3), mb_substr(self::$test_str, 1, 3, mb_detect_encoding(self::$test_str)));
     $this->assert_equal(MultiByte::substr(self::$test_str, 5), mb_substr(self::$test_str, 5));
     printf(" MultiByte substring (begin-1 end-3): %s <br>", MultiByte::substr(self::$test_str, 1, 3));
     printf(" MultiByte substring 2 (begin-5 end-null): %s <br>", MultiByte::substr(self::$test_str, 5));
     printf(" mbstring substring without encoding detected (begin-1 end-3): %s <br>", mb_substr(self::$test_str, 1, 3));
     printf(" mbstring substring with encoding detected (begin-1 end-3): %s <br>", mb_substr(self::$test_str, 1, 3, mb_detect_encoding(self::$test_str)));
     printf(" mbstring substring 2 without encoding detected(begin-5 end-null): %s <br>", mb_substr(self::$test_str, 5));
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:16,代码来源:test_multibyte.php

示例2: test_detect_encoding

 public function test_detect_encoding()
 {
     $this->assert_equal(MultiByte::detect_encoding('foo'), 'ASCII');
     $str = MultiByte::convert_encoding($this->test_strings['jis'], 'JIS');
     $this->assert_equal(MultiByte::detect_encoding($str), 'JIS');
 }
开发者ID:habari,项目名称:tests,代码行数:6,代码来源:test_multibyte.php

示例3: convert_encoding

 public static function convert_encoding($str, $use_enc = null, $from_enc = null)
 {
     $ret = false;
     $enc = self::$hab_enc;
     if ($use_enc !== null) {
         $enc = $use_enc;
     }
     if (self::$use_library == self::USE_MBSTRING) {
         if ($from_enc == null) {
             $from_enc = MultiByte::detect_encoding($str);
         }
         $ret = mb_convert_encoding($str, $enc, $from_enc);
     }
     return $ret;
 }
开发者ID:ringmaster,项目名称:system,代码行数:15,代码来源:multibyte.php

示例4: test_detect_encoding

 public function test_detect_encoding()
 {
     $this->assert_false(MultiByte::detect_encoding('foo'));
 }
开发者ID:habari,项目名称:tests,代码行数:4,代码来源:test_multibyte_native.php

示例5: testDetect_encoding

	public function testDetect_encoding()
	{
		$this->assertEquals( MultiByte::detect_encoding( self::$test_str ), mb_detect_encoding( self::$test_str ) );
	}
开发者ID:rick-c,项目名称:tests,代码行数:4,代码来源:multiByteTest.php

示例6: convert_encoding

 public static function convert_encoding($str, $use_enc = null, $from_enc = null)
 {
     $ret = FALSE;
     $enc = self::$hab_enc;
     if ($use_enc !== null) {
         $enc = $use_enc;
     }
     if (self::$use_library == self::USE_MBSTRING) {
         if (extension_loaded('mbstring')) {
             if ($from_enc == null) {
                 $from_enc = MultiByte::detect_encoding($str);
             }
             $ret = mb_convert_encoding($str, $enc, $from_enc);
         }
     }
     return $ret;
 }
开发者ID:anupom,项目名称:my-blog,代码行数:17,代码来源:multibyte.php

示例7: test_detect_encoding

		public function test_detect_encoding ( ) {
			
			$this->assert_equal( MultiByte::detect_encoding( 'foo' ), 'ASCII' );
			$this->assert_equal( MultiByte::detect_encoding( $this->test_strings['jis'] ), 'JIS' );
			//echo MultiByte::detect_encoding( '' ); die();
			
		}
开发者ID:rynodivino,项目名称:tests,代码行数:7,代码来源:test_multibyte.php


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