3 ms·
https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file https://docs.microsoft.com/en-us/windows/desktop/FileIO/nami... > the file system treats
by ChrisSD 7y ago
https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file https://docs.microsoft.com/en-us/windows/desktop/FileIO/nami...
> the file system treats path and file names as an opaque sequence of WCHARs.
In essence I think you should use UTF-16 encoded strings when creating file paths. However, when reading them you can't assume any encoding (aside for the special characters mentioned in that article). For accessing the filesystem, just treat paths as an opaque blob of data. When displaying a name to the user, assume UTF-16 encoding but handle any decoding errors (e.g. by using replacement characters where neceeary).
- burntsushi 7y agoOh, I meant, did you have any links from official docs that said UTF-16 was used? Your advice is fine, but when the rest of the world is UTF-8 (including the regex engine), things become quite a bit trickier!
- ChrisSD 7y agoOh I see. UTF-16 is the preferred encoding for all new applications: https://docs.microsoft.com/en-us/windows/desktop/intl/unicode https://docs.microsoft.com/en-us/windows/desktop/intl/unicod... Basically, in Windows land, unicode means UTF-16 unless code pages are mentioned https://docs.microsoft.com/en-us/windows/desktop/intl/code-pages https://docs.microsoft.com/en-us/windows/desktop/intl/code-p...