I just spent some hours to solve a problem that many people must have :
How to correctly show Latin accent characters in rails?
The problem is that usually, you get all '?' when sending to the
browser things like 'ç', 'ã' etc.
I spent many hours dealing with this, but couldn't find a good solution
from Mr. Google.
So, I wrote the following method :
asci = Hash.new
for i in 1..255
asci[i.chr] = i
string.each_char do |charac|
saida = saida+ "&#"+asci[charac].to_s
You should put it either in the application_helper.rb and at the
controllers application.rb, so that you can call it either from a view
and from a controller.
Basically, it encodes the string in '&#' codes that are standard html
for the 'monkey' browser.
outputs as :
and not as aten??o
Sorry that it is not elegant enough, I had to make a ascii hash, since
I couldn't find a standard Ruby function to do this.
If someone can help, please post.