On Sep 19, 2008, at 8:12 AM, James Gray wrote:

> Interestingly, I was having basically the same idea for fixing my  
> problem.  I thought I would read() some byte count and try a  
> harmless operation on the end of the String that would trigger the  
> bad data error, if it is there.  While it is, I would keep reading  
> one more byte.

This strategy seems to work.  However, avoid my "try a harmless  
operation on the end of the String that would trigger the bad data  
error" idea.  I ran into trouble with that route.  Instead, use  
String#valid_encoding?.

James Edward Gray II