From: Martin Duerst Date: 2007-12-22T13:58:02+09:00 Subject: Re: io.c patch for two encodings in file mode Hello David, Thanks for this patch. I think Matz was planning to work on this, and probably won't mind your help. At 08:46 07/12/22, David Flanagan wrote: >The attached patch adds support for filemodes like "r:utf-8:iso-8859-15" to io.c. Works for reading and writing. Also, it adds the external_encoding method to ARGF as well (and always returns the default external encoding for that stream). > >This is only minimally tested, but I've verified that it can convert a Euro sign from ISO-8859-15 to UTF-8 and back for reading and writing. > >To do the transcoding, I just rb_funcall to String.encode. There might be more efficient ways to do it later. Yes, and more appropriate, especially for stateful encodings, but for the moment, just using String#encode is fine. Regards, Martin. >I'm not confident that I've got everything done correctly, but I offer the patch in the hope that it helps with the last-minute rush to release 1.9.1. > > David #-#-# Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University #-#-# http://www.sw.it.aoyama.ac.jp mailto:duerst@it.aoyama.ac.jp