From: Michael Selig Date: 2008-09-22T12:12:35+09:00 Subject: [ruby-core:18780] Re: Character encodings - a less radical suggestion On Mon, 22 Sep 2008 12:51:19 +1000, James Gray wrote: > On Sep 21, 2008, at 9:35 PM, Martin Duerst wrote: > >> In terms of potential problems, I see the following: >> - A library sets Encoding::default_internal. That would lead >> to serious problems, and should be clearly advised against >> in the documentation. Libraries either have to be written >> in a general way, or have to document that they only work >> with certain values of Encoding::default_internal >> (this proposal would therefore help you, but not e.g. >> James Gray for the CVS library) > > I really think this a bigger minus than this implies. I can name a lot > of libraries that just flat out expect UTF-8 and choke and die on > anything else. Ruby 1.8 has trained us to think this way for many years. That is very true, but the situation exists independent of "default_internal". The mere fact that Ruby supports multiple encodings means that every library *should* check the encodings of strings passed to it and do the appropriate thing, unless it is acceptable to just let an "Encoding Capability Error" be raised. > Now, if someone were to change Encoding.default_interal then all these > libraries will unexpectedly having data changed on them. I'm pretty > sure that would cause massive damage. Also very true, but people can do all sorts of stupid things that will make things break. Normally you would expect that "default_internal" would be set once at the very start, but who are we to enforce that - one day someone will want to change it mid-stream and probably for a good reason! Mike.