From: Larry Kyrala Date: 2011-09-02T03:04:50+09:00 Subject: [ruby-core:39222] [Ruby 1.9 - Bug #5262][Open] invalid multibyte escapes should raise a clearer error Issue #5262 has been reported by Larry Kyrala. ---------------------------------------- Bug #5262: invalid multibyte escapes should raise a clearer error http://redmine.ruby-lang.org/issues/5262 Author: Larry Kyrala Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux] Here's an irb example of the issue using 'curly-quotes': ruby-1.9.2-p290 :001 > "���" => "���" ruby-1.9.2-p290 :002 > "���".encoding => # ruby-1.9.2-p290 :003 > "\���" SyntaxError: (irb):3: invalid multibyte char (UTF-8) (irb):3: invalid multibyte char (UTF-8) from /local/rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `
' I don't think anyone would ever do this on purpose. But it can happen accidentally when copying and pasting snippets from email/text clients. Trying to spot this error can be very difficult because curly quotes are valid UTF-8 chars in this case. I propose that the error be changed to: SyntaxError: (irb):3: invalid escape sequence: '\���'. This would have directed me to the root cause of the problem much sooner. background on the original rails context here: https://gist.github.com/1184533 -- http://redmine.ruby-lang.org