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; }
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; }
/** * Converts a given string into UTF-8 encoded string. * @param string $string The string being converted. * @param string $from_encoding (optional) The encoding that $string is being converted from. If it is omited, the platform character set is assumed. * @return string Returns the converted string. * This function is aimed at replacing the function utf8_encode() for human-language strings. * @link http://php.net/manual/en/function.utf8-encode */ function api_utf8_encode($string, $from_encoding = null) { return u::utf8_encode($string); }
static function filterString($s, $normalization_form = 4, $leading_combining = '◌') { if (false !== strpos($s, "\r")) { // Workaround https://bugs.php.net/65732 $s = str_replace("\r\n", "\n", $s); $s = strtr($s, "\r", "\n"); } if (preg_match('/[\\x80-\\xFF]/', $s)) { if (n::isNormalized($s, $normalization_form)) { $n = ''; } else { $n = n::normalize($s, $normalization_form); if (false === $n) { $s = u::utf8_encode($s); } else { $s = $n; } } if ($s[0] >= "�" && false !== $n && isset($leading_combining[0]) && preg_match('/^\\p{Mn}/u', $s)) { // Prevent leading combining chars // for NFC-safe concatenations. $s = $leading_combining . $s; } } return $s; }