Hi, Progressing through my learning phase, I wanted to implement a way to i14e my application, and I''m using Ri18n, which so far, works perfectly. However, data returned from the database (as opposed to the .po files) gets mangled. It appears Rails/Ruby thinks the encoding used in MySQL is latin1, which it isn''t. How do I make ActiveRecord behave? Or am I missing something? Thanks in advance! Ivan V.
Did you try this? http://wiki.rubyonrails.org/rails/pages/HowToUseUnicodeStrings Jacob On 10/17/05, Iván Vega Rivera <ivanvr@tangoco.com> wrote:> Hi, > > Progressing through my learning phase, I wanted to implement a way to > i14e my application, and I'm using Ri18n, which so far, works perfectly. > > However, data returned from the database (as opposed to the .po files) > gets mangled. It appears Rails/Ruby thinks the encoding used in MySQL is > latin1, which it isn't. > > How do I make ActiveRecord behave? Or am I missing something? > > Thanks in advance! > > Ivan V. > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
> However, data returned from the database (as opposed to the .po files) > gets mangled. It appears Rails/Ruby thinks the encoding used in MySQL is > latin1, which it isn''t. > > How do I make ActiveRecord behave? Or am I missing something?I saw this somewhere. In application.rb put this def configure_charsets # Set content type. @response.headers["Content-Type"] = "text/html; charset=utf-8" # Set connection charset. MySQL 4.0 doesn''t support this so it # will throw an error, MySQL 4.1 needs this suppress(ActiveRecord::StatementInvalid) do ActiveRecord::Base.connection.execute ''SET NAMES UTF8'' end end /Kasper
Jacob Quinn Shenker wrote:> Did you try this? > http://wiki.rubyonrails.org/rails/pages/HowToUseUnicodeStrings > > Jacob > > On 10/17/05, Iván Vega Rivera <ivanvr-Xl95p0XkWPRBDgjK7y7TUQ@public.gmane.org> wrote: > >> Hi, >> >> Progressing through my learning phase, I wanted to implement a way to >> i14e my application, and I''m using Ri18n, which so far, works perfectly. >> >> However, data returned from the database (as opposed to the .po files) >> gets mangled. It appears Rails/Ruby thinks the encoding used in MySQL is >> latin1, which it isn''t. >> >> How do I make ActiveRecord behave? Or am I missing something? >> >> Thanks in advance! >> >> Ivan V. >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >>I didn''t, thanks for pointing it out! - Ivan.
*Perfect* Thanks a lot! Ivan V. Kasper Weibel wrote:>> However, data returned from the database (as opposed to the .po files) >> gets mangled. It appears Rails/Ruby thinks the encoding used in MySQL is >> latin1, which it isn''t. >> >> How do I make ActiveRecord behave? Or am I missing something? >> > > > I saw this somewhere. In application.rb put this > > def configure_charsets > # Set content type. > @response.headers["Content-Type"] = "text/html; charset=utf-8" > # Set connection charset. MySQL 4.0 doesn''t support this so it > # will throw an error, MySQL 4.1 needs this > suppress(ActiveRecord::StatementInvalid) do > ActiveRecord::Base.connection.execute ''SET NAMES UTF8'' > end > end > > /Kasper > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
> *Perfect* Thanks a lot!You''re welcome. I found the page where I picked this up http://www.ruphus.com/blog/2005/06/23 /getting-unicode-mysql-and-rails-to-cooperate/ More insights here http://wiki.rubyonrails.com/rails/pages/Internationalization /K