# Unicode trouble (incredibly clueless)

**URL:** <https://www.ruby-forum.com/t/unicode-trouble-incredibly-clueless/107247>\
**Category:** Rails\
**Created:** [June 19, 2007, 5:28pm UTC](https://www.ruby-forum.com/t/unicode-trouble-incredibly-clueless/107247 "2007-06-19T17:28:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![taro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df705f/32.png) [@taro](https://www.ruby-forum.com/u/taro)\
**Post date:** [June 19, 2007, 5:28pm UTC](https://www.ruby-forum.com/t/unicode-trouble-incredibly-clueless/107247/1 "2007-06-19T17:28:01Z")

</div>

I bought Agile Web D. With Rails, and followed most of it’s  
directions on setting up the database to accept and decipher utf-8.  
Up to this point, it works wonderfully (especially for a website with  
some Japanese translations) except for one problem: ruby (don’t think  
it’s rail’s fault) doesn’t seem to accept Japanese letters in their  
code.

When I command, “rake db:migrate”, it gives me an error that character  
“\336” in one of my migration is indecipherable. I suspect rake is  
having a problem with the default value I’ve given a migration to  
insert for a Japanese name. Furthermore, I need a hash to  
automatically translate a few english words into japanese. Assuming  
the problem resides in ruby itself, there’s no way I can make one  
inside rail’s controller. Is there some way to initialize a hash with  
english words as keys, and japanese words (as in, Chars objects) as  
buckets outside of migration/controller/model, and import that into a  
migration/controller/model?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![taro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df705f/32.png) [@taro](https://www.ruby-forum.com/u/taro)\
**Post date:** [June 20, 2007, 1:06am UTC](https://www.ruby-forum.com/t/unicode-trouble-incredibly-clueless/107247/2 "2007-06-20T01:06:08Z")

</div>

Hello Taro,

The problem with using hiragana, karakana or kanji is that Rails will  
not be able to work out what the pluralizations are. Further, I am  
not sure what sort of support you will get from databases having kana  
table names or column names.

Ruby is written by a Japanese guy (Matz) and it is all in English.  
The reason for this I believe is that almost all programming languages  
use English as a base language. I would recommend keeping your table  
names and all code in the default language of English. This will also  
avoid future possible bugs that come up because the new plugin you  
installed only handles English table names.

If you must, you can put romanji in the table names, this would be  
close enough. But then you would also need to define custom  
pluralizations for all of these tables as Rails will not know what the  
plural of nihonjin would be. In fact… there isn’t even a plural in  
your language for that… so you might have a problem there 🙂

Instead, just use JapanesePerson for your model which pluralises to  
japanese\_people (which would be your table name) and all will be  
good.

As a side note, I am doing a LOT of work with Japanese characters and  
Rails and Ruby handle them fine! Just make sure to use ActiveSupport  
Multibyte .chars method whenever you are dealing with those UTF8  
characters.

Later

Mikel

---

<div class="post-metadata">

**Author:** ![taro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df705f/32.png) [@taro](https://www.ruby-forum.com/u/taro)\
**Post date:** [June 20, 2007, 6:00pm UTC](https://www.ruby-forum.com/t/unicode-trouble-incredibly-clueless/107247/3 "2007-06-20T18:00:02Z")

</div>

Sorry, maybe I wasn’t clear enough: my model contains english names  
AND japanese names (of course, in seperate columns). The trouble is,  
in my migration, I want to set a certain column’s default value to a  
japanese word.

I could probably do this in my model program instead. Would that work  
out? Does rail model’s run even with japanese characters in them?

And, on a side note, why the heck can’t Rad Rails read unicode  
charaters? Is it due to Eclipse itself?
