Proposal #3337: expose Unicode and newline translation from System.IO

Simon Marlow marlowsd at gmail.com
Mon Jul 6 09:39:34 EDT 2009


On 05/07/2009 13:15, Ian Lynagh wrote:
> On Tue, Jun 30, 2009 at 01:03:17PM +0100, Simon Marlow wrote:
>>   * http://www.haskell.org/~simonmar/base/System-IO.html#23
>>     System.IO (Unicode encoding/decoding)
>
> Is it possible to make an
>      availableEncodings :: IO [(String, TextEncoding)]
> ?

No way that I know of.  iconv doesn't give you a way to enumerate the 
available encodings.

> Also, mkTextEncoding says that it throws an isDoesNotExistError if the
> named encoding doesn't exist, but the code in base at least looks like
> it throws InvalidArgument on Windows, and nothing on other platforms.
> Perhaps it's different in your tree, though.

It throws NoSuchThing on Windows:

mkTextEncoding e = ioException
      (IOError Nothing NoSuchThing "mkTextEncoding"
           ("unknown encoding:" ++ e)  Nothing Nothing)

but on Unix, you're right, there's no exception until the encoding is 
instantiated, which happens when a Handle is opened.  I'll look into 
fixing this.

Cheers,
	Simon


More information about the Libraries mailing list