网址链接中的非英文 Windows 目录名称


Non-English Windows directory name in url link

我有一个php文件,可以搜索计算机的Windows目录。如果我有一个目录包含非英语字符,如"Önder Şoğlopıpk",则返回 null。我的 Php 文件是这样的:

$port = $_GET["port"];//Here is computer's port
$path = trim($_GET["path"]);//Here is the path which does not work
$path = str_replace(" ","+",$path);
$path = urlencode($path);
$suffix = $_GET["suffix"];//Here is suffix which I am searching
if($_GET){ 
$url='http://mylink.com?host=localhost&port='.$port.'&showerrorinxml=yes&link=proc_list?find_files___path='.$path.'___suffix='.$suffix.'';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($data);

如果路径变量中有一个非英语字符,例如"Ş Ğ ı ş ğ I",它会向我返回 null。如果是英语,没有问题。我可以搜索我想要的东西。我正在编码它,但它没有用。我的网址似乎是名为"Seçpa Yazılım Login"的目录是:

http://mylink.com?host=localhost&port=44833&showerrorinxml=yes&link=proc_list?find_files___path=D%3A%2FSe%C3%A7pa%2BYaz%C4%B1l%C4%B1m%2BLogin%2F___suffix=.css

在浏览器上似乎可以:

http://mylink.com?host=localhost&port=44833&showerrorinxml=yes&link=proc_list?find_files___path=D%3A%2FSeçpa%2BYazılım%2BLogin%2F___suffix=.css

有人对这个话题有想法吗?

检索

输入后需要urldecode输入:

$path = trim( urldecode( $_GET['path'] ) );

更新:好的,更仔细地阅读您的问题。对我来说,似乎您要对 URL 进行两次编码。第一次通过 HTTP 请求从浏览器发送它,第二次隐式$path = urlencode( $path );