# Newbe Question: Character Encoding

**URL:** <https://www.ruby-forum.com/t/newbe-question-character-encoding/53138>\
**Category:** Rails\
**Created:** [January 26, 2006, 10:53am UTC](https://www.ruby-forum.com/t/newbe-question-character-encoding/53138 "2006-01-26T10:53:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cneuhaus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/34f0e0/32.png) [@cneuhaus](https://www.ruby-forum.com/u/cneuhaus)\
**Post date:** [January 26, 2006, 10:53am UTC](https://www.ruby-forum.com/t/newbe-question-character-encoding/53138/1 "2006-01-26T10:53:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cneuhaus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/34f0e0/32.png) [@cneuhaus](https://www.ruby-forum.com/u/cneuhaus)\
**Post date:** [January 26, 2006, 1:25pm UTC](https://www.ruby-forum.com/t/newbe-question-character-encoding/53138/2 "2006-01-26T13:25:29Z")

</div>

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](http://www.informatikamihelac.com)  
 → tools, scripts, tricks from our code lab: [http://source.mihelac.org](http://source.mihelac.org)

---

<div class="post-metadata">

**Author:** ![cneuhaus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/34f0e0/32.png) [@cneuhaus](https://www.ruby-forum.com/u/cneuhaus)\
**Post date:** [January 27, 2006, 8:41pm UTC](https://www.ruby-forum.com/t/newbe-question-character-encoding/53138/3 "2006-01-27T20:41:03Z")

</div>

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](http://www.informatikamihelac.com)  
> → tools, scripts, tricks from our code lab: [http://source.mihelac.org](http://source.mihelac.org)
