I have to present german umlaute as "?" on my webpage. When writing the text within the view, everything is fine - the characters are presented correctly. When I declare variable within the controller (e.g. via flash or as a list of values for a listbox) the text is displayed with the umlaute replaced by strange characters. I assume I have to adjust the character encoding somewhere. I am runnin Rails in the standard configuration. On which places can this be done in Rails ? Thanks a lot in advance Christian -- Posted via http://www.ruby-forum.com/.
class ApplicationController < ActionController::Base before_filter :set_charset def set_charset @headers["Content-Type"] = "text/html; charset=ISO-8859-2" end } this works for me for iso-8859-2 character set. best, Bojan Christian Neuhaus wrote:> I have to present german umlaute as "?" on my webpage. When writing the > text within the view, everything is fine - the characters are presented > correctly. When I declare variable within the controller (e.g. via flash > or as a list of values for a listbox) the text is displayed with the > umlaute replaced by strange characters. > > I assume I have to adjust the character encoding somewhere. > > I am runnin Rails in the standard configuration. > > On which places can this be done in Rails ? > > Thanks a lot in advance > Christian > >-- Bojan Mihelac Informatika Mihelac, Bojan Mihelac s.p. | www.informatikamihelac.com -> tools, scripts, tricks from our code lab: http://source.mihelac.org
Thanks, this worked. Another trick is, that in SUSE default character encoding is set to UTF-8. When entering strings with Eclipse editor, strings assigned in the controller that are later directly displayed in the view, e.g. via flash will not be displayed correctly as the font is set to ISO-8859 in the browser. So, solution was in addition to change default font in the editor :-) Bojan Mihelac wrote:> class ApplicationController < ActionController::Base > before_filter :set_charset > > def set_charset > @headers["Content-Type"] = "text/html; charset=ISO-8859-2" > end > } > > this works for me for iso-8859-2 character set. > > best, > Bojan > > > Christian Neuhaus wrote: >> On which places can this be done in Rails ? >> >> Thanks a lot in advance >> Christian >> >> > > > -- > Bojan Mihelac > Informatika Mihelac, Bojan Mihelac s.p. | www.informatikamihelac.com > -> tools, scripts, tricks from our code lab: http://source.mihelac.org-- Posted via http://www.ruby-forum.com/.