- # add helper methods
- class String
- def inspect_bytes
- index = 0
- self.each_byte do |b|
- puts "#{index}: #{b} => #{b.chr}"
- index += 1
- end
- end
- def convert_to_utf8
- Iconv.conv('utf8', 'latin1', self)
- end
- end
- # fix invalid data
- record = Model.find bad_id
- record.update_attribute :field, m.field.convert_to_utf8