Skip to content

Instantly share code, notes, and snippets.

@wireframe
Created July 20, 2011 17:45
Show Gist options
  • Select an option

  • Save wireframe/1095469 to your computer and use it in GitHub Desktop.

Select an option

Save wireframe/1095469 to your computer and use it in GitHub Desktop.
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment