encoding and utf-8 exceptions after upgrade to Ruby 1.9.3 and rails 3.2

ever since I uploaded my new version to production from time to time I get encoding and utf-8 exceptions like these:

Encoding::CompatibilityError: incompatible encoding regexp match (Windows-31J regexp with UTF-8 string)

ArgumentError: invalid byte sequence in UTF-8

after seeing some post i added ot my application.rb

config.encoding = "utf-8"

What is it? and how do I fix? thanks

Answers


I had the same problem occuring "sometimes", I use now at the very top of each .rb files the following:

# encoding: UTF-8

class Whatever < ActiveRecord::Base
  ...
end

The problem occurs when the file contains one/several accent(s) (as a french guy, I sometimes use it in comments).


Need Your Help

Server-side DataTable Sorting in RichFaces

java ajax jsf richfaces

I have a data table with a variable number of columns and a data scroller. How can I enable server side sorting? I prefer that it be fired by the user clicking the column header.

Search dynamic term twice in Regex

php regex preg-replace preg-match

I know I can refer in replacement to dynamic parts of the term in regex in PHP: