From: Brian Candler Date: 2009-07-24T02:02:39+09:00 Subject: Re: Byte–stream parsing in Ruby I've briefly read sections 8 to 11 again. Where does it say that String#<< can now raise an exception, and under what circumstances?. Ah, I finally found it, right at the end of the *comments* at the bottom of section 8, added a month after initial publication. (+) Where does it say that the encoding of a String can change when you concatenate another string onto it? By "undocumented" I mean: I expect to type "ri String#<<" and see an accurate description of what String#<< does, including which combinations of inputs are valid and which are not, and which attributes of the String may mutate based on the input supplied. Regards, Brian. (+) There is a warning in the string *comparisons* section saying that, basically, the rules are too complicated to understand, so you should always ensure that two strings are in the same encoding before comparing them. Arguably you could say the same applies to any other operation which takes two strings. But this to me shows the whole exercise is futile. If, in order to write a valid program, you need to ensure that all strings are in the same encoding, then there should be a global flag which sets the encoding. If I cannot predict what will happen when string A (encoding X) encounters string B (encoding Y), and I have to keep forcing the encodings to X, then there's no benefit in having the capability for strings to carry about their own encodings. And in many apps, the encoding information is carried "out of band" anyway: for example: in HTTP or MIME, the encoding info is in a Content-Type: header. -- Posted via http://www.ruby-forum.com/.