本文整理汇总了PHP中Patchwork\Utf8::utf8_encode方法的典型用法代码示例。如果您正苦于以下问题:PHP Utf8::utf8_encode方法的具体用法?PHP Utf8::utf8_encode怎么用?PHP Utf8::utf8_encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Patchwork\Utf8
的用法示例。
在下文中一共展示了Utf8::utf8_encode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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;
}
示例4: api_utf8_encode
/**
* 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);
}
示例5: filterString
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;
}