Forum: Ruby on Rails Newbe Question: Character Encoding

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Christian N. (Guest)
on 2006-01-26 11:53
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 M. (Guest)
on 2006-01-26 14:25
(Received via mailing list)
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 M.
Informatika Mihelac, Bojan M. s.p.  |  www.informatikamihelac.com
-> tools, scripts, tricks from our code lab: http://source.mihelac.org
Christian N. (Guest)
on 2006-01-27 21:41
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 M. 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 M.
> Informatika Mihelac, Bojan M. s.p.  |  www.informatikamihelac.com
> -> tools, scripts, tricks from our code lab: http://source.mihelac.org
This topic is locked and can not be replied to.