我有一个使用正则表达式的自定义路由器。
问题是我无法解析希腊字符。
以下是一些来自index.php
:
$router->get('/theatre/plays', 'TheatreController', 'showPlays');
$router->get('/theatre/interviews', 'TheatreController', 'showInterviews');
$router->get('/theatre/[-\w\d\!\.]+', 'TheatreController', 'single_post');
以下是一些来自Router.php
:
$found = 0;
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); //get the url
////// Bla Bla Bla /////////
if ( $found = preg_match("#^$value$#", $path) )
{
//Do stuff
}
现在,当我尝试像这样的网址时http://kourtis.app/theatre/α
(注意最后一个字符是希腊语“alpha”)然后它以某种方式解释为http://kourtis.app/theatre/%CE%B1
当我var_dump($path)
或者当我复制粘贴网址时。
我想这与编码有关,但所有内容(我能想到的)都是 utf-8 格式。
有任何想法吗?
--------------------------------
更新:在评论中提出建议后,以下内容适用于仅与一些希腊字符:/theatre/[α-ωΑ-Ω-\w\d\!\.]+
并使用urldecode
解码百分比编码$path
多变的。
产生错误的一些字符是:κ
π
ρ
χ
.
现在的问题是……为什么?
(顺便说一句,这适用于许多字符/theatre/.+
)