On Dec 26, 2008, at 4:22 AM, Martin Duerst wrote:

> Hello James,

Hello.

> Akira wrote the text below, and Matz said it should
> somehow get to you. I'm not sure whether Akira has the
> time to do this, so here's a short summary.

As always, I really appreciate you doing these translations.

> Akira thinks that what you tried to do in CSV#inspect
> is to somehow produce an ASCII-compatible encoding.

Akira is right that I was trying to do this.

I really don't know if this is the right strategy though.  How should  
we be handling inspect messages?

> If that's your intent, then a simple force_encoding
> won't work well for UTF-16, because it will leave
> some 0x00 bytes in the string.
>
> 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.

It's good advice.  I appreciate the help.

> On the same problem, Yugui suggested that the encoding
> of the string returned by inspect should be the encoding
> of the file.

Yeah, I saw that in another message.

How would I do that exactly?  Will trying the simple join() you  
purposed in your initial message naturally bring everything to UTF8-MAC?

James Edward Gray II