# UTF-8 not working (Mac OS X)

**URL:** <https://www.ruby-forum.com/t/utf-8-not-working-mac-os-x/130271>\
**Category:** Rails\
**Created:** [February 26, 2008, 10:58pm UTC](https://www.ruby-forum.com/t/utf-8-not-working-mac-os-x/130271 "2008-02-26T22:58:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeronimo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@jeronimo](https://www.ruby-forum.com/u/jeronimo)\
**Post date:** [February 26, 2008, 10:58pm UTC](https://www.ruby-forum.com/t/utf-8-not-working-mac-os-x/130271/1 "2008-02-26T22:58:39Z")

</div>

I’m trying to get UTF-8 working, but I can’t get it work fully. I have  
the data in my MySQL-database, the tables and fields are in utf-8  
charset. If I query the database from the terminal, all UTF-8  
characters show up nicely.

The pages I’m outputting have the following header

```
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/

```

> 

And Unicode characters I’m putting directly into the view files are  
also showing up correctly. The encoding parameter in database.yml is  
set to utf8. However, strings from the database are output mangled,  
both in Safari and Firefox.

Is there anything I’ve missed?

I’m running Mac OS X 10.5.2, Rails 2.0.2, Ruby 1.8.6, MySQL gem 2.7.

Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![jeronimo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@jeronimo](https://www.ruby-forum.com/u/jeronimo)\
**Post date:** [February 27, 2008, 10:36am UTC](https://www.ruby-forum.com/t/utf-8-not-working-mac-os-x/130271/2 "2008-02-27T10:36:15Z")

</div>

could be just a question of the font used in your browsers?  
did you check the generated html-source?

---

<div class="post-metadata">

**Author:** ![jeronimo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@jeronimo](https://www.ruby-forum.com/u/jeronimo)\
**Post date:** [March 10, 2008, 1:12pm UTC](https://www.ruby-forum.com/t/utf-8-not-working-mac-os-x/130271/3 "2008-03-10T13:12:58Z")

</div>

On Feb 27, 6:17 am, jeronimo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > could be just a question of the font used in your browsers?  
> > did you check the generated html-source?
> 
> Yes, I checked: the UTF-8characters from the database are output as  
> several different characters, so somewhere UTF-8 was interpreted  
> incorrectly, but I have no clue where.

I had the same problem, tried everything and it came down to removing/  
commenting out the ‘encoding’ line from each environment section of my  
database.yml.

---

<div class="post-metadata">

**Author:** ![jeronimo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@jeronimo](https://www.ruby-forum.com/u/jeronimo)\
**Post date:** [February 27, 2008, 11:17am UTC](https://www.ruby-forum.com/t/utf-8-not-working-mac-os-x/130271/4 "2008-02-27T11:17:25Z")

</div>

> could be just a question of the font used in your browsers?  
> did you check the generated html-source?

Yes, I checked: the UTF-8characters from the database are output as  
several different characters, so somewhere UTF-8 was interpreted  
incorrectly, but I have no clue where.

---

<div class="post-metadata">

**Author:** ![jeronimo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@jeronimo](https://www.ruby-forum.com/u/jeronimo)\
**Post date:** [March 10, 2008, 1:23pm UTC](https://www.ruby-forum.com/t/utf-8-not-working-mac-os-x/130271/5 "2008-03-10T13:23:37Z")

</div>

On Feb 27, 6:17 am, jeronimo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > could be just a question of the font used in your browsers?  
> > did you check the generated html-source?
> 
> Yes, I checked: the UTF-8characters from the database are output as  
> several different characters, so somewhere UTF-8 was interpreted  
> incorrectly, but I have no clue where.

I had the same problem, tried everything and it came down to removing/  
commenting out the ‘encoding’ line from each environment section of my  
database.yml.
