# UTF-8 in migrations: problem with broken chars in db

**URL:** <https://www.ruby-forum.com/t/utf-8-in-migrations-problem-with-broken-chars-in-db/56557>\
**Category:** Rails\
**Created:** [April 1, 2006, 3:17am UTC](https://www.ruby-forum.com/t/utf-8-in-migrations-problem-with-broken-chars-in-db/56557 "2006-04-01T03:17:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6bbea6/32.png) [@marcan](https://www.ruby-forum.com/u/marcan)\
**Post date:** [April 1, 2006, 3:17am UTC](https://www.ruby-forum.com/t/utf-8-in-migrations-problem-with-broken-chars-in-db/56557/1 "2006-04-01T03:17:15Z")

</div>

I need to put some data into the database using migrations. The data  
needs to be in UTF-8 format (since the database and the rest of the  
Rails application is UTF-8). It doesn’t work.

I have set up the UTF-8 support in environment.rb (which works perfectly  
in the rest of the application). I have also tested to save the  
migration file as a UTF-8 file (variable char length), as a unicode file  
(double bytes) and as latin1 file (none works, just gives different  
crappy chars in db). It still doesn’t work. What should I do to make it  
work?

Rails 1.1, Ruby 1.8.4, Windows XP Pro, MySQL 4.1.11.nt with  
ENGINE=InnoDB DEFAULT CHARSET=utf8 on all tables.

Thanks,

Marcus

---

<div class="post-metadata">

**Author:** ![marcan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6bbea6/32.png) [@marcan](https://www.ruby-forum.com/u/marcan)\
**Post date:** [April 1, 2006, 3:38am UTC](https://www.ruby-forum.com/t/utf-8-in-migrations-problem-with-broken-chars-in-db/56557/2 "2006-04-01T03:38:28Z")

</div>

Forget about this. It works now for some reason…

/Marcus

Marcus A. skrev:
