我在一个CentOS服务器上安装了PHP,我想把文件从这里(用PHP FTP)传输到一个运行IIS的Windows FTP服务器上。现在我的问题是,当文件名包含非拉丁字符时,它会将文件名更改为类似‘تست.3gp’的名称(它在CentOS中的名称是.3gp)我已经搜索了很多次,但没有解决方案。我该如何解决这个问题?
我认为Windows使用CP-1252 (Windows-1252)作为字符集,而CentOS使用UTF-8作为字符集。但是使用iconv()和mb_convert_encoding()进行转换并不起作用。
发布于 2013-03-03 19:18:37
经过多次研究,我找到了答案。windows对不同的语言使用不同的字符集。对于这些字符集的编码,我们可以使用这个类:http://www.phpclasses.org/package/1360-PHP-Conversion-between-many-character-set-encodings.html
发布于 2013-03-03 20:13:19
我们也可以在mb_convert_encoding()中使用这些编码
// Cyrillic script such as Russian, Bulgarian, Serbian Cyrillic and other languages Windows-1251 ~= ISO-8859-5
// Latin alphabet Windows-1252 ~= ISO-8859-1 // sometimes called incorrectly "ANSI"
//modern Greek. It is not capable of supporting the older polytonic Greek. It is not fully compatible with ISO 8859-7 because the letters like Ά are located at different byte values Windows-1253 ~= ISO-8859-7
// Turkish Windows-1254 = ISO-8859-9
// Hebrew Windows-1255 = ISO-8859-8
// Arabic script like Persian and Urdu Windows-1256 ~= ISO-8859-6
// Estonian, Latvian and Lithuanian languages Windows-1257 != ISO-8859-4
// Vietnamese texts. It is very similar to Windows-1252 with the differences being that s-caron and z-caron Windows-1258 ~= Windows-1252我将这些代码用于波斯语文件名:
$filename=iconv('UTF-8','Windows-1256//IGNORE',$filename);https://stackoverflow.com/questions/15176742
复制相似问题