PHP: How to create unicode filenames

后端 未结 4 849
死守一世寂寞
死守一世寂寞 2020-12-03 22:48

I\'m trying to create files with Unicode characters in there filenames. I don\'t quite know what encoding I should use, or if it\'s possible at all.

I have this file

4条回答
  •  不思量自难忘°
    2020-12-03 23:12

    Filenames do not have a notion of encoding. You have to figure out the filename by other means. The only important point for your situation is that in most filesystems a filename is a null-terminated *byte*string, but in NTFS it is a null-terminated 16-bit-string. Consequently, you cannot use the standard fopen-type functions to access all possible NTFS filenames.

    However, if you have obtained the NTFS filename of an existing file by other means, you can use the Windows API function GetShortPathName to obtain the short name of the file, which you can use in fopen. I don't know if PHP lets you access Windows API functions, though, but perhaps someone has written a module or plugin for that.

提交回复
热议问题