我在使用mkdir
我在xampp
上使用windows
,当我尝试创建directory
时,它返回的不像应该是,例如
mkdir(JPATH_SITE.'/images/projects/'.$region_folder.'/'.$project_folder, 0777, true);
应该返回类似
的内容/images/projects/Ленинградская_область/Ленинградская_область_1
但是要创建一个directory
,如:
/images/projects/Ленинградская_область/Ленинградская_область_1
关于编码的事情是什么?或者与操作系统有关?
答案 0 :(得分:2)
Windows文件名不是用utf8编码的,而是windows-1252
或windows-1251
或类似的。
试试这个:
$dirname = JPATH_SITE.'/images/projects/'.$region_folder.'/'.$project_folder;
//replace "UTF-8" with the respective input charset, if it is not utf8
$dirname = iconv("UTF-8","Windows-1252",$dirname);
mkdir($dirname, 0777, true);
//if this doesnt work, try another charset like this:
$dirname = iconv("UTF-8","Windows-1251",$dirname);
//you can also use iconv on your russian variables only
//remember that you might need to change UTF-8 to another input charset
$region_folder = iconv("UTF-8","Windows-1251",$region_folder);
$project_folder = iconv("UTF-8","Windows-1251",$project_folder);
在此处详细了解iconv:PHP iconv()
也可用于检测您的字符集编码:mb_detect_encoding()