Foundation will do what it needs to do internally to make its API work, including converting paths to other encodings, but you should never have to.
As @compnerd noted: you can pass a string you receive from the user to URL(fileURLWithPath:)
to turn it into a URL, and on Windows that can be a string that is a valid Windows path when typed. If you need to pass it to Win32/WinRT API, you can use .fileSystemRepresentation
, which on Windows is defined to be the UCS-2 encoding expected by the SomethingSomethingW
family of functions.
Swift System has abstractions for concepts shared by OSes, but for the more abstract concept of 'this is a location on disk where a file or folder can be read or written' in the core libraries, the currency type Foundation-and-higher levels use is effectively Foundation.URL
when the scheme is file
, just like on Darwin.