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; }
/** * @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)); } } }
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; }
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; }
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; }
/** * Checks a string for UTF-8 validity. * */ function api_is_valid_utf8($string) { return u::isUtf8($string); }
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)); }