
On 09/11/2011 13:11, Ian Lynagh wrote:
On Wed, Nov 09, 2011 at 11:02:54AM +0000, Simon Marlow wrote:
I would be happy with the surrogate approach I think. Arguable if you try to treat a string with lone surrogates as Unicode and it fails, then that is a feature: the original string wasn't Unicode. All you can do with an invalid Unicode string is use it as a FilePath again, and the right thing will happen.
If we aren't going to guarantee that the encoded string is unicode, then is there any benefit to encoding it in the first place?
With a decoded FilePath you can: - use it as a FilePath argument to some other function - map all the illegal characters to '?' and then treat it as Unicode, e.g. for printing it out (but then you lost the ability to roundtrip, which is why we can't do this automatically). Ok, so since we need something like makePrintable :: FilePath -> String arguably we might as well make that do the locale decoding. That's certainly a good point... Cheers, Simon