Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.34 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # add helper methods
  2. class String
  3.   def inspect_bytes
  4.       index = 0
  5.       self.each_byte do |b|
  6.         puts "#{index}: #{b} => #{b.chr}"
  7.         index += 1
  8.       end
  9.   end
  10.   def convert_to_utf8
  11.     Iconv.conv('utf8', 'latin1', self)
  12.   end
  13. end
  14.  
  15. # fix invalid data
  16. record = Model.find bad_id
  17. record.update_attribute :field, m.field.convert_to_utf8