Skip to content

Instantly share code, notes, and snippets.

@nick1123
Created April 19, 2013 15:17
Show Gist options
  • Save nick1123/5421037 to your computer and use it in GitHub Desktop.
Save nick1123/5421037 to your computer and use it in GitHub Desktop.
s = "hello\xdf".force_encoding("ASCII-8BIT")
s.encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "")
@spencerroan
Copy link

java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01-447-11M4203)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01-447, mixed mode)

@spencerroan
Copy link

java -version

@spencerroan
Copy link

1.9.3p374 :001 > s = "hello\xdf".force_encoding("ASCII-8BIT") 
 => "hello\xDF" 
1.9.3p374 :002 > s.encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "")
 => "hello"  
1.9.3p374 :004 > RUBY_PLATFORM
 => "x86_64-darwin11.4.2" 
1.9.3p374 :005 > RUBY_VERSION
 => "1.9.3" 

you can see that it is patch 374.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment