From: James Gray Date: 2008-12-27T02:02:41+09:00 Subject: [ruby-core:20888] Re: [ruby-dev:37591] [BUG:trunk] [m17n] TestCSVFeatures fails because of r20905 On Dec 25, 2008, at 12:02 AM, Martin Duerst wrote: > The easiest fix for this, which is probably what was intended, > is to change the above line to > > str.map { |s| s.force_encoding("ASCII-8BIT") }.join > > A slightly more "user-friendly" fix is to change this to > something like: > > begin > str.join > rescue > str.map { |s| s.force_encoding("ASCII-8BIT") }.join > end > > This will only do a force_encoding if the encodings can't > be joined as is. On Dec 26, 2008, at 4:22 AM, Martin Duerst wrote: > What Akira proposes is to use > > e = Encoding::Converter.asciicompat_encoding(s.encoding) > e ? s.encode(e) : s.force_encoding("ASCII-8BIT") > > i.e. to convert to an ASCII-compatible encoding from > the current encoding if necessary and possible, otherwise > to force the data to be interpreted as ASCII-8BIT. I've combined these two suggestions for now. If we come up with a best practice for inspect() messages though, I would love to hear it. James Edward Gray II