本文整理汇总了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));
}
示例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');
}
示例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;
}
示例4: test_detect_encoding
public function test_detect_encoding()
{
$this->assert_false(MultiByte::detect_encoding('foo'));
}
示例5: testDetect_encoding
public function testDetect_encoding()
{
$this->assertEquals( MultiByte::detect_encoding( self::$test_str ), mb_detect_encoding( self::$test_str ) );
}
示例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;
}
示例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();
}