Skip to content

Instantly share code, notes, and snippets.

@norman
Created March 29, 2010 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norman/348261 to your computer and use it in GitHub Desktop.
Save norman/348261 to your computer and use it in GitHub Desktop.
$ irb
ruby-1.9.1-p378 > string = "Jürgen Müller"
=> "Jürgen Müller"
ruby-1.9.1-p378 > string.force_encoding("BINARY").encode("UTF-8", :invalid => :replace, :replace => "")
Encoding::UndefinedConversionError: "\xC3" from ASCII-8BIT to UTF-8
from (irb):2:in `encode'
from (irb):2
from /Users/norman/.rvm/rubies/ruby-1.9.1-p378/bin/irb:17:in `<main>'
ruby-1.9.1-p378 >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment