本文整理匯總了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;
}
}