I’m trying to get this code to work (ruby 1.8.7):
line = "abc"
"#{line}☃".encode('utf-8')[0..-2].scan(/\p{Katakana}/)
but it returns undefined method 'encode' for "abc\342\230\203":String (NoMethodError).
You can run the program here: http://codepad.org/nh6cAqHT
You are probably using an older version of ruby. It is available in 1.9.3
but not in 1.8.7, so check which version you’re using.
Works fine.