# Strange problem with accentuated characters

**URL:** <https://www.ruby-forum.com/t/strange-problem-with-accentuated-characters/91482>\
**Category:** Rails\
**Created:** [April 9, 2007, 5:58pm UTC](https://www.ruby-forum.com/t/strange-problem-with-accentuated-characters/91482 "2007-04-09T17:58:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![josealvarez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b38774/32.png) [@josealvarez](https://www.ruby-forum.com/u/josealvarez)\
**Post date:** [April 9, 2007, 5:58pm UTC](https://www.ruby-forum.com/t/strange-problem-with-accentuated-characters/91482/1 "2007-04-09T17:58:11Z")

</div>

I have a menu controller that has the configuration for the menus in  
my web. Each action is a menu and I have a function “opcion” that  
creates options that are stored in an array @opciones this way:  
[{:nombre =\> “name”,:controller =\> “controller”, :action=\>  
“action”}…] This array is later used in the view to create link\_to  
items.  
In this code I have the menu “secciones” with three options:

def secciones  
@opciones = Array.new  
@opciones \<\< opcion(“LifeSTech”,“lst”,“index”)  
@opciones \<\< opcion(“Investigacion”,“investigacion”,“index”)  
@opciones \<\< opcion(“Publicaciones”,“publicacion”,“index”)  
end

private  
def opcion(nombre,controller,action)  
return {:nombre =\> nombre, :controller =\> controller, :action=\>  
action}  
end

In the view “secciones.rhtml” I have:

\<% @opciones.each do |opcion| %\>  
\<%= link\_to opcion[:nombre], {:controller =\>  
opcion[:controller],:action =\> opcion[:action]}, :class =\>  
“enlaces\_contenidos”%\>  
\<% end %\>

This works perfectly if I have no accents, but if I use  
“Investigacion” instead of “Investigación” it gives me this error:

./script/…/config/…/app/controllers/menu\_controller.rb:7: syntax  
error, unexpected tIDENTIFIER, expecting ‘)’  
@opciones \<\< opcion(“Investigación”,“investigacion”\_-\>parsererror\<-  
\_,“index”)

_-\>parsererror\<-_ marks the point where the parser crashes

The file is ANSI but I’ve tried with UTF-8 and I have not solved the  
question. I think the problem is specific to rails 1.2.\* because this  
code works with accents in 1.1 with this code in the application.rb:

after\_filter :set\_charset

def set\_charset  
headers[“Content-Type”] ||= “text/html; charset=iso-8859-1”  
end

This code does not work anymore with rails 1.2.

I would appreciate any help.

Thank you
