Skip to content

Instantly share code, notes, and snippets.

@cypher
Created April 26, 2010 13:50
Show Gist options
  • Save cypher/379346 to your computer and use it in GitHub Desktop.
Save cypher/379346 to your computer and use it in GitHub Desktop.
eschaton :: ~/Projects » cat scratch.rb
# encoding: utf-8
str = "This is ä strïng with ümläuts in it"
regex = / (\p{Alpha}) /
puts __ENCODING__
puts str.encoding
puts regex.encoding
if str =~ regex
puts "match: #{$1.inspect}"
else
puts "No match :("
end
eschaton :: ~/Projects » rvm ruby scratch.rb
ruby-1.9.1-p376: ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-darwin10.3.0]
UTF-8
UTF-8
UTF-8
match: "ä"
ruby-1.9.2-preview1: ruby 1.9.2dev (2009-07-18 trunk 24186) [i386-darwin10.2.0]
UTF-8
UTF-8
UTF-8
match: "ä"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment