I'm getting two errors, both revolving around encoding and both related.
The first error (technically, a warning) I get when starting up WEBrick:
/Users/USERNAME/example/config/initializers/bb-ruby.rb:54: warning: invalid Unicode Property \P: /\:\-?\P/
The line it's referring to is: /\:\-?\P/,
It's just a bit of regex, ultimately part of this block:
@@tags['Razzing'] = [
/\:\-?\P/,
'<img src="/assets/emoticons/razzing.png">',
'Razzing',
':P',
:razzing]
Then, I also get the following error when parsing some strings (presumably due to this same line)...
Encoding::CompatibilityError
incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string)
I'm running Ruby 1.9.2 and Rails 3.2.1.
Your Regex is being "compiled" as ASCII-8BIT.
Just add the encoding declaration at the top of the file where the Regex is declared:
# encoding: utf-8
And you're done. Now, when Ruby is parsing your code, it will assume every literal you use (Regex, String, etc) is specified in UTF-8 encoding.
UPDATE: UTF-8
is now the default encoding for Ruby 2.0 and beyond.
Ruby 2.0 Document
/Pattern/u - stand for UTF-8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With