當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Utf8::utf8_decode方法代碼示例

本文整理匯總了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);
}
開發者ID:ragebat,項目名稱:chamilo-lms,代碼行數:12,代碼來源:internationalization.lib.php

示例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;
     }
 }
開發者ID:pyjac,項目名稱:BSSB,代碼行數:17,代碼來源:Bootup.php


注:本文中的Patchwork\Utf8::utf8_decode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。