/**
 * 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
0
파일: Bootup.php 프로젝트: pyjac/BSSB
 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;
     }
 }