
John Millikin wrote:
Perhaps I'm misunderstanding, but the definition of 'withFilePath' you provided is definitely locale-dependent. Unless getFileSystemEncoding is constant?
I think/hope it's locale dependent, but undecodable bytes are remapped, so as long as the system's locale doesn't change, reading a FilePath with the encoding and then writing it back out should always reproduce the same bytes.
Filesystem.Path.CurrentOS.toText is a nice option if you want validly encoded output though. Thanks for that!
Ah, that's not what toText is for. toText provides a human-readable representation of the path. It's used for things like file managers, where you need to show the user a label which approximates the underlying path. There's no guarantee that the output of toText can be converted back to the original path, especially if it returns a Left.
Yes, that's what I meant. :) -- see shy jo