----- Original Message ----- 
From: "Martin Duerst" <duerst / it.aoyama.ac.jp>
To: <ruby-core / ruby-lang.org>
Sent: Thursday, October 02, 2008 2:36 PM
Subject: [ruby-core:19102] Re: Encodings::default_internal patch


> Setting default_internal to default_external is essentially the
> same as setting default_internal to nil, so it's mostly a question
> of internal program structure and internal interfaces.

Actually it isn't.

If you take the program fragment:

f1 = open("/tmp/junk1", "r:UTF-8")
s1 = f1.gets
f2 = open("/tmp/junk2", "r:EUC-JP")
s2 = f2.gets

When executed with both "default_external" and "default_internal" set to 
UTF-8, both s1 & s2 will be UTF-8 strings.
When executed with default_internal nil, s1 will be UTF-8, but s2 will be 
EUC-JP (so they will be incompaitble).

> I think the main question is whether it's worth, later in the
> program, to be able to distinguish between
> a) a user explicitly setting a default_internal that happens
>   to be the same as default_external and
> b) default_internal not being set and therefore being equal
>   to default_internal.

IMHO the main reason to query default_internal is when deciding what 
encoding to return a string in when it isn't clear from the inputs. Sorry, 
but I don't see much point in falling back to default_external is 
default_internal is nil.

Cheers
Mike