Category: Programming
A Web Developer’s Responsibility
How to file a good browser bug report: http://ejohn.org/blog/a-web-developers-responsibility/
Netbeans 6.9.x / RVM – invalid multibyte escape: /[\x80-\xFF]/ (SyntaxError)
Problem
You have a Rails project in Netbeans 6.9.x and got a following error while trying to start WEBBrick:
1 | aws/s3/extensions.rb:84: invalid multibyte escape: /[\x80-\xFF]/ (SyntaxError) |
Solution
Add the following line to your /usr/local/netbeans-6.9.1/etc/netbeans.conf:
1 | -J-Druby.no.kcode=true |
Original bug report: http://netbeans.org/bugzilla/show_bug.cgi?id=158794
HOWTO Escape a Unicode string with Ruby
From: http://stackoverflow.com/questions/5560914/how-do-i-escape-a-unicode-string-with-ruby
Ruby 1.8.x:
1 2 3 4 5 6 7 8 9 | >> multi_byte_str = "hello\330\271!" => "hello\330\271!" >> multi_byte_str.inspect => "\"hello\\330\\271!\"" >> puts multi_byte_str.inspect "hello\330\271!" => nil |
Ruby 1.9
1 2 | >> multi_byte_str.bytes.to_a.map(&:chr).join.inspect => "\"hello\\xD8\\xB9!\"" |
Ruby 1.8 and 1.9 – Unicode code points
1 2 | >> multi_byte_str.unpack('U*').map{ |i| "\\u" + i.to_s(16).rjust(4, '0') }.join => "\\u0068\\u0065\\u006c\\u006c\\u006f\\u0639\\u0021" |