# Special characters?

**URL:** <https://www.ruby-forum.com/t/special-characters/76931>\
**Category:** Rails\
**Created:** [March 5, 2006, 6:28pm UTC](https://www.ruby-forum.com/t/special-characters/76931 "2006-03-05T18:28:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [March 5, 2006, 6:28pm UTC](https://www.ruby-forum.com/t/special-characters/76931/1 "2006-03-05T18:28:22Z")

</div>

I’m not sure if this is something in Rails or MySQL, but characters like  
Ã¼ are showing up funky in my app. I see ‘Ã¼’ in the DB using a query  
browser, but in the app it shows up as ‘A1/4.’ Do I need to use another  
charset or something?

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [March 5, 2006, 7:44pm UTC](https://www.ruby-forum.com/t/special-characters/76931/2 "2006-03-05T19:44:01Z")

</div>

Chris S. wrote:

> I’m not sure if this is something in Rails or MySQL, but characters like  
> Ã¼ are showing up funky in my app. I see ‘Ã¼’ in the DB using a query  
> browser, but in the app it shows up as ‘A1/4.’ Do I need to use another  
> charset or something?

try to modify your ApplicationController:

* * *

# Filters added to this controller will be run for all controllers in

the application.

# Likewise, all the methods added will be available for all controllers.

class ApplicationController \< ActionController::Base  
before\_filter :set\_charset

```
def set_charset
    @headers["Content-Type"] = "text/html; charset=iso-8859-1"
end

```

end

* * *

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [March 5, 2006, 8:45pm UTC](https://www.ruby-forum.com/t/special-characters/76931/3 "2006-03-05T20:45:54Z")

</div>

That almost worked… It is displaying properly, except when I update a  
list with an ajax call. In the list, it it still showing as ‘A1/4.’  
However if I display the list normally (using the list action) it looks  
ok. Strange…

last resort wrote:

> Chris S. wrote:
> 
> > I’m not sure if this is something in Rails or MySQL, but characters like  
> > Ã¼ are showing up funky in my app. I see ‘Ã¼’ in the DB using a query  
> > browser, but in the app it shows up as ‘A1/4.’ Do I need to use another  
> > charset or something?
> 
> try to modify your ApplicationController:
> 
> * * *
> 
> # Filters added to this controller will be run for all controllers in
> 
> the application.
> 
> # Likewise, all the methods added will be available for all controllers.
> 
> class ApplicationController \< ActionController::Base  
> before\_filter :set\_charset
> 
> ```
> def set_charset
> @headers["Content-Type"] = "text/html; charset=iso-8859-1"
> end
> 
> ```
> 
> end
> 
> * * *

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [March 5, 2006, 9:00pm UTC](https://www.ruby-forum.com/t/special-characters/76931/4 "2006-03-05T21:00:49Z")

</div>

Chris

```
> That almost worked... It is displaying properly, except when I

```

update a  
\> list with an ajax call. In the list, it it still showing as  
‘A1/4.’

You can set the header manually before rendering the partial :

```
 def update_partial_stuff
      ...
     @headers["Content-Type"] = "text/html; charset=utf-8"
     render :partial => 'foo'
 end

```

Alain

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [March 5, 2006, 9:12pm UTC](https://www.ruby-forum.com/t/special-characters/76931/5 "2006-03-05T21:12:22Z")

</div>

Still no joy…I think it’s because I’m using RJS templates to update  
the list. In my .rjs I tried:

@headers[“Content-Type”] = “text/html; charset=utf-8”  
page.insert\_html :bottom, ‘cardList’, :partial =\> ‘card\_chunk\_add’

Alain R. wrote:

> Chris
> 
> ```
> > That almost worked... It is displaying properly, except when I
> 
> ```
> 
> update a  
> \> list with an ajax call. In the list, it it still showing as  
> ‘A1/4.’
> 
> You can set the header manually before rendering the partial :
> 
> ```
> def update_partial_stuff
> ...
> @headers["Content-Type"] = "text/html; charset=utf-8"
> render :partial => 'foo'
> end
> 
> ```
> 
> Alain

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [March 5, 2006, 9:51pm UTC](https://www.ruby-forum.com/t/special-characters/76931/6 "2006-03-05T21:51:59Z")

</div>

I think the problem is that RJS changes the content type to  
text/javascript. If anyone knows how to get around this bug let me  
know.

Chris S. wrote:

> Still no joy…I think it’s because I’m using RJS templates to update  
> the list. In my .rjs I tried:
> 
> @headers[“Content-Type”] = “text/html; charset=utf-8”  
> page.insert\_html :bottom, ‘cardList’, :partial =\> ‘card\_chunk\_add’
> 
> Alain R. wrote:
> 
> > Chris
> > 
> > ```
> > > That almost worked... It is displaying properly, except when I
> > 
> > ```
> > 
> > update a  
> > \> list with an ajax call. In the list, it it still showing as  
> > ‘A1/4.’
> > 
> > You can set the header manually before rendering the partial :
> > 
> > ```
> > def update_partial_stuff
> > ...
> > @headers["Content-Type"] = "text/html; charset=utf-8"
> > render :partial => 'foo'
> > end
> > 
> > ```
> > 
> > Alain
