本文整理汇总了PHP中Patchwork\Utf8::utf8_decode方法的典型用法代码示例。如果您正苦于以下问题:PHP Utf8::utf8_decode方法的具体用法?PHP Utf8::utf8_decode怎么用?PHP Utf8::utf8_decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Patchwork\Utf8
的用法示例。
在下文中一共展示了Utf8::utf8_decode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: api_utf8_decode
/**
* Converts a given string from UTF-8 encoding to a specified encoding.
* @param string $string The string being converted.
* @param string $to_encoding (optional) The encoding that $string is being converted to. 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_decode() for human-language strings.
* @link http://php.net/manual/en/function.utf8-decode
*/
function api_utf8_decode($string, $to_encoding = null)
{
return u::utf8_decode($string);
}
示例2: filterRequestUri
static function filterRequestUri()
{
// Ensures the URL is well formed UTF-8
// When not, assumes Windows-1252 and redirects to the corresponding UTF-8 encoded URL
if (isset($_SERVER['REQUEST_URI']) && !preg_match('//u', urldecode($a = $_SERVER['REQUEST_URI']))) {
if ($a === u::utf8_decode($a)) {
$a = preg_replace_callback('/(?:%[89A-F][0-9A-F])+/i', function ($m) {
return urlencode(u::utf8_encode(urldecode($m[0])));
}, $a);
} else {
$a = '/';
}
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $a);
exit;
}
}