From: Tor L. <tm...@ik...> - 2011-10-31 05:32:28
|
> attributes = GetFileAttributesA (filename); Note that this works only if "filename" is the file name expressed in the "system codepage" encoding, though. File names in Windows are in Unicode, and it is perfectly possible, and in some locales might even be quite common, to have files and directories with names that can't be expressed in the system codepage. (Example: Hebrew file names in an Arabic localisation of Windows, Greek file names in a German localisation of Windows.) So in the remote chance that you plan to use code like this for some functionality that somebody might find useful to prevent from working properly on purpose, be prepared: Creating files with arbitrary Unicode names isn't hard. To work in general, you should handle file names in Unicode (typically either UTF-16, which is the encoding that Windows itself and the Microsoft C/C++ library use for their wide-character API, like GetFileAttributesW() or _wfopen(), or UTF-8, which is what much open source software uses, and then convert to/from UTF-16 for Windows and C library wide-character API calls). --tml |