# RoR + MySQL + Unicode

**URL:** <https://www.ruby-forum.com/t/ror-mysql-unicode/99605>\
**Category:** Rails\
**Created:** [July 24, 2006, 1:50pm UTC](https://www.ruby-forum.com/t/ror-mysql-unicode/99605 "2006-07-24T13:50:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![piekarka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/848f3c/32.png) [@piekarka](https://www.ruby-forum.com/u/piekarka)\
**Post date:** [July 24, 2006, 1:50pm UTC](https://www.ruby-forum.com/t/ror-mysql-unicode/99605/1 "2006-07-24T13:50:50Z")

</div>

hello! I have a problem when I want to display data in Unicode from  
database. I read [this  
tutorial](http://ruphus.com/blog/2005/06/23/getting-unicode-mysql-and-rails-to-cooperate/) but I still have problem with non-English characters. I  
don’t have any other idea what I should do. Did you meet with similat  
problem? Have you got any idea? Thanks in advance.

---

<div class="post-metadata">

**Author:** ![piekarka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/848f3c/32.png) [@piekarka](https://www.ruby-forum.com/u/piekarka)\
**Post date:** [July 24, 2006, 3:56pm UTC](https://www.ruby-forum.com/t/ror-mysql-unicode/99605/2 "2006-07-24T15:56:57Z")

</div>

Hi, Agnieszka,

have you made sure that you’ve got and encoding: utf8 directive in your  
database.yaml config file?

Cheers,  
Jan

---

<div class="post-metadata">

**Author:** ![piekarka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/848f3c/32.png) [@piekarka](https://www.ruby-forum.com/u/piekarka)\
**Post date:** [July 25, 2006, 3:15pm UTC](https://www.ruby-forum.com/t/ror-mysql-unicode/99605/3 "2006-07-25T15:15:34Z")

</div>

hello!  
Yes, I’m sure. My database.yml file looks like:

development:  
adapter: mysql  
database: \*\*\*  
encoding: utf8  
username: \*\*\*  
password: \*\*\*  
host: \*\*\*  
port: \*\*\*

etc…  
but is it possible that problem lies in fact that my database in on Unix  
environment but I work on Windows. May this connection cause a special  
probelem?  
I look for special coding, parameters in Ruby source but I find nothing.

---

<div class="post-metadata">

**Author:** ![piekarka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/848f3c/32.png) [@piekarka](https://www.ruby-forum.com/u/piekarka)\
**Post date:** [July 25, 2006, 10:08pm UTC](https://www.ruby-forum.com/t/ror-mysql-unicode/99605/4 "2006-07-25T22:08:43Z")

</div>

Hi,

just another guess: Have you installed the mysql gem on your windows  
box?

gem install mysql

Cheers,  
Jan

---

<div class="post-metadata">

**Author:** ![piekarka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/848f3c/32.png) [@piekarka](https://www.ruby-forum.com/u/piekarka)\
**Post date:** [July 25, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/ror-mysql-unicode/99605/5 "2006-07-25T22:09:09Z")

</div>

Are you testing the application in webrick?  
If it’s load webrick with the option -c utf-8 (ruby script/server -c  
utf-8)

Another thing that you can try is in your templates put the next:

 .... ....

it’s redundant(theoretically), but in some cases it’s ok.

## Regards

View this message in context:  
[http://www.nabble.com/RoR-%2B-MySQL-%2B-Unicode-tf1991783.html#a5487770](http://www.nabble.com/RoR-%2B-MySQL-%2B-Unicode-tf1991783.html#a5487770)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![piekarka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/848f3c/32.png) [@piekarka](https://www.ruby-forum.com/u/piekarka)\
**Post date:** [July 26, 2006, 9:23am UTC](https://www.ruby-forum.com/t/ror-mysql-unicode/99605/6 "2006-07-26T09:23:32Z")

</div>

Thanks for advice!  
… but my application doesn’t display non-English characters. I  
installed mysql gem and try charset iso-8859-1. Nothing …  
I use text\_field\_with\_auto\_complete and there I display data from  
database. May it cause problem? And when application display data from  
database method find(:all) is executed? I decoded data in database as  
utf-8 and I read data in utf-8 coding.  
Are used special codings from reading from database to display in  
application?  
Thanks.

---

<div class="post-metadata">

**Author:** ![piekarka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/848f3c/32.png) [@piekarka](https://www.ruby-forum.com/u/piekarka)\
**Post date:** [July 26, 2006, 8:25pm UTC](https://www.ruby-forum.com/t/ror-mysql-unicode/99605/7 "2006-07-26T20:25:41Z")

</div>

I had similar problems, and after trying everything…

I noticed that the problem was my database client… I mean, I used the  
windows “console” to execute the mysql client for loading the data and  
special characters displayed a ‘?’ on my browser, but when I used a rake  
task to load data, special characters were displayed correctly.

I don’t know why… but I worked for me… I hope it helps you…

---

<div class="post-metadata">

**Author:** ![piekarka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/848f3c/32.png) [@piekarka](https://www.ruby-forum.com/u/piekarka)\
**Post date:** [July 26, 2006, 8:34pm UTC](https://www.ruby-forum.com/t/ror-mysql-unicode/99605/8 "2006-07-26T20:34:57Z")

</div>

Try using an encoding of chaset uft-8, that may work. As long as your  
database is set to work with utf-8 and you also have this set in your  
database yml file this should (theoretically) work.

- Sarah
