I'm trying out the unidecoder gem and it's giving me problems with some strings:
require 'unidecoder'
str = "\u00A3"
str.to_ascii
#: (C:/Ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder/data/x00.yml): found unknown escape character while parsing a quote d scalar at line 2 column 3 from C:/Ruby193/lib/ruby/1.9.1/psych.rb:203:in
parse' from C:/Ruby193/lib/ruby/1.9.1/psych.rb:203:inparse_stream' from C:/Ruby193/lib/ruby/1.9.1/psych.rb:151:inparse' from C:/Ruby193/lib/ruby/1.9.1/psych.rb:127:inload' from C:/Ruby193/lib/ruby/1.9.1/psych.rb:297:inblock in load_file' from C:/Ruby193/lib/ruby/1.9.1/psych.rb:297:inopen' from C:/Ruby193/lib/ruby/1.9.1/psych.rb:297:inload_file' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:8:inblock in ' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:78:inyield' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:78:indefault' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:78:indecode_char' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:39:inblock in decode' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:37:ingsub' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:37:indecode' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:16:into_ascii' from (irb):21 from C:/Ruby193/bin/irb:12:in'>>
What's worse, I can't catch the error by doing:
foo = str.to_ascii rescue 'x'
Does anyone know what's happening here?
rescue clause with no parameter list, the parameter defaults to StandardError; it looks like
unidecoderraises kinda other exception, but the stacktrace seems to be incomplete (it should show the exception type.)