本文整理汇总了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;
}
示例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));
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例6: api_is_valid_utf8
/**
* Checks a string for UTF-8 validity.
*
*/
function api_is_valid_utf8($string)
{
return u::isUtf8($string);
}
示例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));
}