From: Vincent Isambart Date: 2007-12-29T07:05:04+09:00 Subject: Re: Ruby 1.9 and Unicode > Any explanation for the differences in the rows in the following? > > http://intertwingly.net/stories/2007/12/28/hearts.rb > http://intertwingly.net/stories/2007/12/28/hearts.html Well I have to admit I do not understand well the behavior of doc.root.elements[2].text. Something is definitively strange with it: doc.root.elements[2].text.ascii_only? returns true, whereas it should only return true for strings containing only ASCII (7bits) characters You can see the same behavior replacing in your program "text << doc.root.elements[2].text" by "text << 'A'.force_encoding(nil)". And the reason why 'A'.force_encoding(nil) can be safely added to any other string in any other encoding is that Ruby only manipulate strings in encodings in which ASCII characters are "safe" and do not have any special meaning (it means it rules out the ISO-2022, UTF-16 and UTF-32 and such). So the fact that ascii_only? returns true for this text is probably a bug in either REXML, Ruby or both. But as you said in your post REXML is not developed very actively so I'm not astonished it does not work so well. Some people have made small patches to make it work on 1.9, but I think that's all. And after all Ruby 1.9.0 is still beta so it's time to iron out the bugs ;).