Rename the Chinese name file under Windows 10 64 and PHP 5.6, prompting the wrong solution
1. Rename the file name in a directory, its code, as shown in Figure 1
2. Error: rename(e:/wwwroot/avatar/beiji/housen.jpg, e:/wwwroot/avatar/beiji/378477.jpg): ϵͳ�ҳ���ָ�����ļ�� (code: 2), as shown in Figure 2
3. Use the file_exists function to check whether the file exists, if it exists, print 1, if not, print 0, as shown in Figure 3
4. The print result is 0, indicating that the result of the check file does not exist, as shown in Figure 4
5. Open the URL:http://php.net/manual/zh/function.rename.php, found a hint: to solve such problems, as shown in Figure 5
Translation: on Windows (XP, Vista, 7…)http://fr.wikipedia.org/wiki/Windows-1252“,如果你的文件名包含口音,它基本上不起作用,所以使用iconv函数从UTF-8 to CP1252 are as follows:
6. Iconv — The string is converted according to the required character encoding, converting the string e:/wwwroot/avatar/beiji/housen.jpg from UTF-8 to convert the encoding to GB2312, code, as shown in Figure 6
7. The print result is 1, indicating that the result of the inspection file exists, as shown in Figure 7
8. The final implementation code, as shown in Figure 8
9. The files in the directory e:/wwwroot/avatar/beiji, as shown in Figure 9
10. Run the script, the file in the directory e:/wwwroot/avatar/beiji has been renamed successfully, as shown in Figure 10
11. Run the script and report an error: iconv(): detected an illegal character in input string, as shown in Figure 11
Translation: iconv(): illegal characters detected in the input string
12. Print the file name and find that the illegal character should be Wu Qi, as shown in Figure 12
13. Modify GB2312 to GB18030 (if it is modified to GBK, it will still report an error, the GB18030 character set contains GBK character set and Chinese, Japan and South Korea (CJK) EXT-A ), as shown in Figure 13












