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.
C591df8c5b86e0ff3a93ae55d161d002?d=identicon&s=25 Christian Neuhaus (cneuhaus)
on 2006-01-26 10: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
866edcb271e88be4bfd935eea7947730?d=identicon&s=25 Bojan Mihelac (Guest)
on 2006-01-26 13: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 Mihelac
Informatika Mihelac, Bojan Mihelac s.p.  |  www.informatikamihelac.com
-> tools, scripts, tricks from our code lab: http://source.mihelac.org
C591df8c5b86e0ff3a93ae55d161d002?d=identicon&s=25 Christian Neuhaus (cneuhaus)
on 2006-01-27 20: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 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
This topic is locked and can not be replied to.