From: James Gray Date: 2009-04-16T23:54:09+09:00 Subject: Re: querying using HTTP On Apr 16, 2009, at 2:31 AM, Brian Candler wrote: > Peter Bailey wrote: >> I'm querying a graphics database using http. > > ... and ruby 1.9.1, it appears > >> On my server and on my PC, >> I can successfully run a simple script that checks for the >> existence of >> files in different formats—PDF, PNG, and TIFF. But, when my >> colleagues >> run this same script, they get the error I display below. > > ruby 1.9's runtime behaviour of anything using String varies depending > on the environment it runs in. That's not accurate. Certain encoding options have default settings relating to the environment they run in, but none of that matters if specify the desired encodings for your source and/or IO objects. These defaults are provided as conveniences so that simple scripting can fit in naturally with the rest of the environment. Removing the defaults would just mean more work for the programmer as you would be forced to specify all encodings even in situations where a default makes sense. I also don't think it's bad to say that a programmer must specify the encoding of data they wish to read. How in the world can we expect Ruby to get a gets() call right on a UTF-16LE file without us providing a warning about what the data is? > It is quite difficult to get it behave sanely, and is such a mess > that I stick with ruby 1.8. Ruby 1.8 had a single global variable that, when set, changed the behavior of all code in the interpreter, including the stuff I didn't write. I hope that isn't your idea of a "sane" system. Ruby 1.9 probably does require us to learn the bare minimum about how character encodings are handled. It's about time. How many years have we tried to get by with crossed fingers and a prayer that it would just work out? Character encodings should have been required reading long before now. For those who are ready to learn the basics, the new Pickaxe has a solid 13 page introduction. It doesn't take long to work through and it covers the important stuff. If you want to go farther, I've covered character encoding basics, the Ruby 1.8 system, and the new 1.9 system a bit deeper in a series of posts to my blog: http://blog.grayproductions.net/articles/understanding_m17n > If those don't work, then I'd suggest you stick with ruby 1.8 for the > next year or so. For years the Ruby community has begged for more speed and robust character encoding support. The core team delivered that and much more this January with a production release that's substantially faster and has a very powerful new encoding engine. To repay their monumental efforts, we complain and urge people to stick with Ruby 1.8. We must truly be the most ungrateful lot of bums ever. For what it's worth, I believe Brian is wrong. I think the best thing we can do as a community is to move everything to Ruby 1.9 as fast as possible. If there are barriers to us doing that, we need find ways to tear them down. There are a lot more plusses than minuses, I promise. Ruby 1.9 is ready for us. Come on in, the water is fine! James Edward Gray II