Hi all, I want to build a Japanese website by RoR. Does RoR support Shift-JIS encoding? Or does it have plug-in support Shift-JIS encoding? Thanks, For Ad Now
on 2008-05-15 06:15
on 2008-05-15 09:19
Although the Rails-Core list is meant for discussion on development of the framework, I would like to reply because the answer is probably not widely known. Rails currently defaults to UTF-8 everywhere. You can, in theory, use Shift-JIS and any other encoding if you like but don't expect it to be easy. You will have to: 1. Make sure your database and data is Shift-JIS 2. Make sure the connection to the database is Shift-JIS (using database.yml and the encoding configuration option) 3. Make sure all Rails internal string handling is Shift-JIS, by writing your own Chars handler (See UTF8Handler), or don't use any text helpers etc. 4. Override the default encoding set in the content-type sent by Rails 5. Set the encoding specifically in your HTML If you don't have any special reason to use Shift-JIS for your project, it's probably easier to just use UTF-8. If you have any further questions don't hesitate to contact me personally. Manfred
on 2008-05-15 09:39
Thank you very much!
on 2008-05-15 16:03
A while ago I was messing with ShiftJIS and found some pretty helpful methods in the RSS::Converter library (in the ruby core lib), such as def_to_utf_8_from_shift_jis() or def_to_utf_8_from_shift_jis(). It does seem a little random using an RSS library if you're not doing RSS stuff, but it worked pretty well for me. The only drawback - from what I understand (correct me if I'm wrong) - is that there are different interpretations of Shift JIS, so the input that you get might not exactly be compatible with your interpreter, -tieg
on 2008-05-16 04:14
On May 15, 1:15 pm, "For Ad" <forad...@gmail.com> wrote: > I want to build a Japanese website by RoR. > Does RoR support Shift-JIS encoding? > > Or does it have plug-in support Shift-JIS encoding? jpmobile plugin can translate UTF-8 to SJIS using filters in controller. You can write your code by UTF-8 and store users' data by UTF-8. http://rubyforge.org/projects/jpmobile/ Although this plugin aims to build websites for mobile phones in Japan, you will find the way to use Shift-JIS in your application.