當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Utf8::isUtf8方法代碼示例

本文整理匯總了PHP中Patchwork\Utf8::isUtf8方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utf8::isUtf8方法的具體用法?PHP Utf8::isUtf8怎麽用?PHP Utf8::isUtf8使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Patchwork\Utf8的用法示例。


在下文中一共展示了Utf8::isUtf8方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: composeReader

 protected function composeReader($o)
 {
     if (is_file($this->realpath) && false !== ($a = file_get_contents($this->realpath))) {
         $a && false !== strpos($a, "\r") && ($a = strtr(str_replace("\r\n", "\n", $a), "\r", "\n"));
         u::isUtf8($a) || ($a = u::utf8_encode($a));
         $o->code = pStudio_highlighter::highlight($a, $this->language, true);
     }
     return $o;
 }
開發者ID:nicolas-grekas,項目名稱:Patchwork-pStudio,代碼行數:9,代碼來源:php.php

示例2: foreach

 /**
  * @covers Patchwork\Utf8::isUtf8
  */
 function testIsUtf8()
 {
     foreach (self::$utf8ValidityMap as $u => $t) {
         if ($t) {
             $this->assertTrue(u::isUtf8($u));
         } else {
             $this->assertFalse(u::isUtf8($u));
         }
     }
 }
開發者ID:nicolas-grekas,項目名稱:Patchwork-sandbox,代碼行數:13,代碼來源:Utf8Test.php

示例3: composeReader

 protected function composeReader($o)
 {
     if (is_file($this->realpath) && false !== ($a = file_get_contents($this->realpath))) {
         $b = @unserialize($a);
         if (false !== $b || $a === serialize(false)) {
             $a = '<?php serialize(' . var_export($b, true) . ')';
             u::isUtf8($a) || ($a = u::utf8_encode($a));
             $o->text = $a;
         }
     }
     return $o;
 }
開發者ID:nicolas-grekas,項目名稱:Patchwork-pStudio,代碼行數:12,代碼來源:ser.php

示例4: composeReader

 protected function composeReader($o)
 {
     if (is_file($this->realpath) && false !== ($a = file_get_contents($this->realpath))) {
         if (preg_match('/[\\x00-\\x08\\x0B\\x0E-\\x1A\\x1C-\\x1F]/', substr($a, 0, 512))) {
             $o->is_binary = true;
         } else {
             $a && false !== strpos($a, "\r") && ($a = strtr(str_replace("\r\n", "\n", $a), "\r", "\n"));
             u::isUtf8($a) || ($a = u::utf8_encode($a));
             $o->text = $a;
         }
     }
     return $o;
 }
開發者ID:nicolas-grekas,項目名稱:Patchwork-pStudio,代碼行數:13,代碼來源:opener.php

示例5: __construct

 public function __construct($data, $inputEncoding = 'UTF-8', $outputEncoding = null)
 {
     if (!is_string($data)) {
         $data = (string) $data;
     }
     if ($inputEncoding == 'UTF-8') {
         if (!Utf8::isUtf8($data)) {
             throw new Exception('Invalid UTF-8 data.');
         }
     } else {
         $data = iconv($inputEncoding, 'UTF-8', $data);
     }
     if (!Normalizer::isNormalized($data, Normalizer::FORM_C)) {
         $data = Normalizer::normalize($data, Normalizer::FORM_C);
     }
     $this->data = $data;
     if (is_null($outputEncoding)) {
         $outputEncoding = $inputEncoding;
     }
     // FIXME validate encoding
     $this->outputEncoding = $outputEncoding;
 }
開發者ID:ogoudat,項目名稱:ogoudat,代碼行數:22,代碼來源:String.php

示例6: api_is_valid_utf8

/**
 * Checks a string for UTF-8 validity.
 *
 */
function api_is_valid_utf8($string)
{
    return u::isUtf8($string);
}
開發者ID:ragebat,項目名稱:chamilo-lms,代碼行數:8,代碼來源:internationalization.lib.php

示例7: test_invalid_six_octet_sequence

 public function test_invalid_six_octet_sequence()
 {
     $str = "Iñtërnâtiônàlizætiøn������Iñtërnâtiônàlizætiøn";
     $this->assertFalse(u::isUtf8($str));
 }
開發者ID:nicolas-grekas,項目名稱:Patchwork-sandbox,代碼行數:5,代碼來源:Utf8IsValidTest.php


注:本文中的Patchwork\Utf8::isUtf8方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。