add ruby 191 hacks for encoding errors