Hi. When I try to use multibyte characters in my rails controller I get an invalid multibyte characters error (<rails_app>/app/controllers/admin_controller.rb:6: invalid multibyte char (US-ASCII)). Here is my controller: contoller AdminController < ApplicationController def read @title = ''Заголовок страницы'' end end Here is my haml template extraction: ... %title= @title ... After I start the WEBrick server and go to http://localhost:3000/admin/read I get the error. However, if I set # encoding: utf-8 on top of the controller file the error disappear. The question is how can I "officially" correct this error? How can I maintain Rails to proper multibyte characters handling? -- Posted via http://www.ruby-forum.com/.
> When I try to use multibyte characters in my rails controller I get an > invalid multibyte characters error > (<rails_app>/app/controllers/admin_controller.rb:6: invalid multibyte > char (US-ASCII)). > > > After I start the WEBrick server and go to > http://localhost:3000/admin/read I get the error. However, if I set # > encoding: utf-8 on top of the controller file the error disappear. > > The question is how can I "officially" correct this error? How can I > maintain Rails to proper multibyte characters handling?Is there a solution to this in 2010? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Fernando Perez wrote in post #923012:> >> When I try to use multibyte characters in my rails controller I get an >> invalid multibyte characters error >> (<rails_app>/app/controllers/admin_controller.rb:6: invalid multibyte >> char (US-ASCII)). >> >> >> After I start the WEBrick server and go to >> http://localhost:3000/admin/read I get the error. However, if I set # >> encoding: utf-8 on top of the controller file the error disappear. >> >> The question is how can I "officially" correct this error? How can I >> maintain Rails to proper multibyte characters handling? > > Is there a solution to this in 2010?Self-reply: is there a solution to this in 2011? I am running Rails 3.0.3 with Ruby 1.9.2 and it still fucks up. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I see this: $ ruby -e ''puts Encoding.find("locale")'' ASCII-8BIT How to set the proper locale/encoding? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
From that url: http://nuclearsquid.com/writings/ruby-1-9-what-s-new-what-s-changed.html "Ruby 1.9 can now properly read source code files encoded in formats other than ASCII, as long as you declare it: # coding: utf-8" Don''t tell me I have to put that in every file of my apps? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Some more configuration to escape error: - Make sure ''config.encoding = "utf-8"'' is there in application.rb file. - Make sure you are using ''mysql2'' gem - Putting ''# encoding: utf-8'' on top of rake file. - Above ''<AppName>::Application.initialize!'' line in environment.rb file, add following two lines: Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 Thanks Ritesh Kumar http://rorguide.blogspot.com/2011/06/incompatible-character-encodings-ascii.html -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Possibly Parallel Threads
- Encoding::UTF_8 missing?
- Illegal multibyte sequence error in pdbedit output
- slow directory access, convert_string_internal: Conversion error: Incomplete multibyte sequence
- [patch] fix bytesize in exception template; multibyte titleize
- feedback on a few ActiveSupport::Multibyte patches