# Dealing with special characters

**URL:** <https://www.ruby-forum.com/t/dealing-with-special-characters/85163>\
**Category:** Rails\
**Created:** [February 10, 2007, 8:35pm UTC](https://www.ruby-forum.com/t/dealing-with-special-characters/85163 "2007-02-10T20:35:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![j-merrill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@j-merrill](https://www.ruby-forum.com/u/j-merrill)\
**Post date:** [February 10, 2007, 8:35pm UTC](https://www.ruby-forum.com/t/dealing-with-special-characters/85163/1 "2007-02-10T20:35:06Z")

</div>

hi all,

what is the best way to deal with non-english characters?

for example, I have a field withthe value “joÃƒÂ£o” after saving the value  
“JoÃ£o”. How do I deal with this issue?

Thnaks

---

<div class="post-metadata">

**Author:** ![j-merrill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@j-merrill](https://www.ruby-forum.com/u/j-merrill)\
**Post date:** [February 10, 2007, 10:54pm UTC](https://www.ruby-forum.com/t/dealing-with-special-characters/85163/2 "2007-02-10T22:54:11Z")

</div>

I’m not an expert, but I have also had some difficulties with this  
before. The key things to resolve this for me were:

1. make sure that your database field formats are correct (e.g. utf-8).
2. add (depending on your database field formats) something like: to your  
layout.

Hope this helps

Darren

Hope this helps

J. mp wrote:

> hi all,
> 
> what is the best way to deal with non-english characters?
> 
> for example, I have a field withthe value “joÃƒÂ£o” after saving the value  
> “JoÃ£o”. How do I deal with this issue?
> 
> Thnaks

---

<div class="post-metadata">

**Author:** ![j-merrill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@j-merrill](https://www.ruby-forum.com/u/j-merrill)\
**Post date:** [February 10, 2007, 11:00pm UTC](https://www.ruby-forum.com/t/dealing-with-special-characters/85163/3 "2007-02-10T23:00:57Z")

</div>

Guest wrote:

> I’m not an expert, but I have also had some difficulties with this  
> before. The key things to resolve this for me were:
> 
> 1. make sure that your database field formats are correct (e.g. utf-8).
> 2. add (depending on your database field formats) something like: to your  
> layout.
> 
> Hope this helps
> 
> Darren
> 
> Hope this helps
> 
> J. mp wrote:
> 
> > hi all,
> > 
> > what is the best way to deal with non-english characters?
> > 
> > for example, I have a field withthe value “joÃƒÂ£o” after saving the value  
> > “JoÃ£o”. How do I deal with this issue?
> > 
> > Thnaks

Thansk,  
I’ve done that already. Thanks  
now my probkem is other 🙂  
in my db i’m saving correclty the string, but I’m now seeking for a way  
to replace all charecters like Ã£, Ã‚, Ã¢, Ã‚, etc by their corresponding  
HTML codes, and I can’t find a way to do that

---

<div class="post-metadata">

**Author:** ![j-merrill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@j-merrill](https://www.ruby-forum.com/u/j-merrill)\
**Post date:** [February 10, 2007, 11:14pm UTC](https://www.ruby-forum.com/t/dealing-with-special-characters/85163/4 "2007-02-10T23:14:05Z")

</div>

On Feb 10, 2007, at 5:00 PM, J. mp wrote:

> > layout.
> > 
> > > what is the best way to deal with non-english characters?  
> > > in my db i’m saving correclty the string, but I’m now seeking for a  
> > > way  
> > > to replace all charecters like ã, Â, â, Â, etc by their corresponding  
> > > HTML codes, and I can’t find a way to do that

There’s no general way to do that since HTML doesn’t define character  
entities for all possible characters. If you’ve specified that utf-8  
is in use throughout (database, Rails [Ruby’s $KCODE], HTML), then  
you shouldn’t need to convert. Of course, the end user may not be  
able to see the character you intend if his/her system lacks a  
suitable font.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid
