Fixed execption on unknown encoding for ruby 1.8 and added a test