On Sep 12, 2011, at 7:20 AM, Robert Klemme wrote:
>=20
>> Now, if you open a file for write and set an external encoding (the
>> default is nil) it means "transcode to this encoding". But for some
>> reason, setting external encoding to ASCII-8BIT bypasses this rule.
>=20
> See above.  The name ASCII-8BIT is probably not the best one to choose
> for this but if you think about it as BINARY then everything fits
> nicely together.

I think the anomaly that Brian pointed out was that the transcoding =
during IO behaved differently than explicit transcoding:

> Normally, transcoding a UTF-8 string (which contains non-ASCII=20
> characters) to ASCII-8BIT would raise an exception:
>=20
> irb(main):006:0> "gro=DF".encode("ASCII-8BIT")
> Encoding::UndefinedConversionError: U+00DF from UTF-8 to ASCII-8BIT
>=20
> But now we have a special case where it *doesn't* raise an exception =
:-(



It makes sense to me that transcoding to 'binary' (or 'ASCII-8BIT') =
would just copy bytes but it doesn't make sense that implicit =
transcoding via IO and explicit transcoding via #encode behave =
differently.

Gary Wright=