Skip to content

Instantly share code, notes, and snippets.

@puffy
Created February 10, 2013 14:46
Show Gist options
  • Save puffy/4749787 to your computer and use it in GitHub Desktop.
Save puffy/4749787 to your computer and use it in GitHub Desktop.
The pretty way to break away of invalid utf-8 byte sequence error in ruby 1.9 # code got from http://robots.thoughtbot.com/post/42664369166/fight-back-utf-8-invalid-byte-sequences
def replace_name(body, name)
body
.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
.gsub(/joel/, name)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment