Solving ‚invalid multibyte escape: /^\xFE\xFF/‘ in ruby vpim


When using Ruby 2.0/2.1 with the vpim gem (tested with version 0.695), you get an error message similar to this:

/usr/local/rvm/gems/ruby-2.1.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require': /usr/local/rvm/gems/ruby-2.1.0/gems/vpim-0.695/lib/vpim/vcard.rb:678: invalid multibyte escape: /^\xFE\xFF/ (SyntaxError)


Edit the vcard.rb file listed in the error message (you need to edit exactly the listed file, not any vcard.rb!).

Prepend the following line — it must be the first line in the file:

# encoding: US-ASCII

That’s it!

With this line, you force Ruby not to interpret the escape characters as a UTF-8 character sequence.