I''ve got a database table (mysql 5.0) that contains Japanese text. The table is set to sjis. I''ve ran the few scripts to get the basic app to interact with the database for rails. However, all Japanese text comes out as question marks ''?''. English text comes out fine. I''ve tried all the encoding on the web browser with no luck. I''ve even recreated the table with utf8 as the default with no luck either. Using Webrick. I''ve gone through the forum and apparently Rails'' support of nonACII characters is sub par. But there''s got to be some way to get some Japanese through? I''ve seen a clip where it works on a Japanese computer. -Anthony -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
You need to set the KCODE global eg $KCODE = ''u'' for utf-8, $KCODE = ''s'' for sjis We do this in environment.rb You may also want to require ''jcode'', this enhances some of the methods in String so that they work properly with multibyte charsets. Fred -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> You need to set the KCODE global > eg $KCODE = ''u'' for utf-8, $KCODE = ''s'' for sjis > > We do this in environment.rb > > You may also want to require ''jcode'', this enhances some of the methods > in String so that they work properly with multibyte charsets. > > FredI tried adding $KCODE = ''u'', but no luck. I tried $KCODE = ''s'' as well. Lastly I tried it with require ''jocde'' added as well, but no go. Hmmm.... -Anthony -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Oh, and also make sure that the browser is correctly determing the content-encoding Fred -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> Oh, and also make sure that the browser is correctly determing the > content-encoding > > FredYeah, I tried all of the encoding settings in FF and IE with no luck. I''ve killed WEBrick and started over everytime I modified environment.rb. -Anthony -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Hi, Did you set "encoding:" to database.yml ? (e.g.) development: adapter: mysql database: depot_development socket: /var/lib/mysql/mysql.sock username: foo password: bar encoding: cp932 cp932 is a subset of shift jis on Windows. "utf8" may be better with Rails. And also you need to set Content-Type correctly. http://nubyonrails.com/articles/2006/02/01/rjs-and-content-type-header On Wed, 1 Nov 2006 17:18:31 +0100 Anthony Walsh <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Frederick Cheung wrote: > > Oh, and also make sure that the browser is correctly determing the > > content-encoding > > > > Fred > > Yeah, I tried all of the encoding settings in FF and IE with no luck. > I''ve killed WEBrick and started over everytime I modified > environment.rb. > > -Anthony > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Between the various responses, people have got it right. The minimum you need is: 1. Your database/table to the right character set 2. Your database connection to the right character set, by putting an "encoding: ..." line in database.yml 3. Make sure Rails is telling the browser the right character set, as per http://nubyonrails.com/articles/2006/02/01/rjs-and-content-type- header I recommend you use utf8. Rails 1.2 will have a lot more tools for handling utf8, and Rails already tells your browser to send utf8 by default, so you can skip step 3. :) Cheers, Pete Yandell http://aliencamel.com/ On 01/11/2006, at 9:33 PM, Anthony Walsh wrote:> > I''ve got a database table (mysql 5.0) that contains Japanese text. The > table is set to sjis. I''ve ran the few scripts to get the basic app to > interact with the database for rails. However, all Japanese text comes > out as question marks ''?''. English text comes out fine. I''ve tried all > the encoding on the web browser with no luck. I''ve even recreated the > table with utf8 as the default with no luck either. Using Webrick. > > I''ve gone through the forum and apparently Rails'' support of nonACII > characters is sub par. But there''s got to be some way to get some > Japanese through? I''ve seen a clip where it works on a Japanese > computer. > > -Anthony > > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Anthony Walsh wrote:> Frederick Cheung wrote: >> Oh, and also make sure that the browser is correctly determing the >> content-encoding >> >> Fred > > Yeah, I tried all of the encoding settings in FF and IE with no luck. > I''ve killed WEBrick and started over everytime I modified > environment.rb. > > -AnthonyI got it! I had to add encoding: utf8 in each of the database stanzas to database.yml. -Anthony -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---