Hannes Larsson
2007-Jun-12 08:14 UTC
How do I change character encoding from UTF-8 to ISO-8859-1?
Hi! I have a Rails application that is using a MSSQL server/database. I need to change the character set encoding to ISO-8859-1. How do I do this??? I have added the defult_cahrset to the environment.rb like: ActionController::Base.default_charset=(''ISO-8859-1'') And I have set the attribute on the meta tag in the header like: <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> And also, since I am using the Aptana RadRails IDE I have set the text-file encoding property to ISO-8859-1. But when I try to populate my database using the migration scripts I get an error saying: syntax error, unexpected tSTRING_BEG unterminated string meets end of file The line of code contains Swedish characters like Å, Ä and Ö. If i remove the Ö, all is fine. But this is not an option. Need help fast!!! Thanks! Hannes -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Xavier Noria
2007-Jun-12 08:55 UTC
Re: How do I change character encoding from UTF-8 to ISO-8859-1?
On Jun 12, 2007, at 10:14 AM, Hannes Larsson wrote:> The line of code contains Swedish characters like Å, Ä and Ö. If i > remove the Ö, all is fine. But this is not an option.Rails sets $KCODE to "UTF8" by default since 1.2. Thus, unless you set $KCODE to something else the Ruby interpreter expects source code in UTF-8. That is, your editor is using latin1 to write the file just fine, but Ruby still expects UTF-8 because you configure that option in the interpreter via $KCODE. Just assign $KCODE = ''NONE'' in environment.rb. Additionally, it would be healthy to explicitely configure the database driver as well in database.yml, in MySQL that would be for example encoding: latin1 -- fxn --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hannes Larsson
2007-Jun-12 10:30 UTC
Re: How do I change character encoding from UTF-8 to ISO-885
Xavier Noria wrote:> On Jun 12, 2007, at 10:14 AM, Hannes Larsson wrote: > >> The line of code contains Swedish characters like �, � and �. If i >> remove the �, all is fine. But this is not an option. > > Rails sets $KCODE to "UTF8" by default since 1.2. > > Thus, unless you set $KCODE to something else the Ruby interpreter > expects source code in UTF-8. That is, your editor is using latin1 to > write the file just fine, but Ruby still expects UTF-8 because you > configure that option in the interpreter via $KCODE. Just assign > > $KCODE = ''NONE'' > > in environment.rb. > > Additionally, it would be healthy to explicitely configure the > database driver as well in database.yml, in MySQL that would be for > example > > encoding: latin1 > > -- fxnThanx a million! added $KCODE = ''NONE'' to environment.rb, now it all works as it suppose to! super and thanx again! /Hannes -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---