If it’s not there try adding the following to ApplicationController:
after_filter :set_charset
def set_charset
content_type = @headers[“Content-Type”] || ‘text/html’
if /^text//.match(content_type) @headers[“Content-Type”] = “#{content_type}; charset=utf-8”
end
end
If anyone has a nicer solution please let me know.
If it’s not there try adding the following to ApplicationController:
after_filter :set_charset
def set_charset
content_type = @headers[“Content-Type”] || ‘text/html’
if /^text//.match(content_type) @headers[“Content-Type”] = “#{content_type}; charset=utf-8”
end
end
Check youre headers for this.
I am having the same problem.
But for me it works in Firefox but not in Safari.
Very, very strange and extremely frustrating… My apps all act a little
different. Either they display the stuff correctly in the Rails app but
e.g. not in phpMyAdmin/CocoaMySQL or vice versa…
But why isn’t there just a switch in Rails that allows me poor german
(swiss german) user to use my beloved umlauts? What about convention
over configuration? In this way Rails is still very unfriendly (also in
things like the auto-generated form validation errors… try to use them
in a german app!)…
You need to make sure your database is set to use UTF8, which it
probably won’t be if you’ve created it in CocoaMySQL. Use ALTER
DATABASE xyz CHARSET=‘utf8’
You need to tell Rails to speak to the database in UTF8 by adding
“encoding: utf8” to each database in database.yml
You need to tell Ruby that you want to use UTF8 by putting the
following in your environment.rb:
require ‘jcode’
$KCODE=‘u’
You need to make Rails pass back the correct content type header
by putting the following in application.rb:
after_filter :set_charset
def set_charset
content_type = @headers[“Content-Type”] || ‘text/html’
if /^text//.match(content_type) @headers[“Content-Type”] = “#{content_type}; charset=utf-8”
end
end
But why isn’t there just a switch in Rails that allows me poor german
(swiss german) user to use my beloved umlauts?
The simple answer is that nobody has built it yet! There are now a
couple of plugins floating around that provide much better unicode
handling, and there’s discussion going on about including some of this
in Rails 1.2. You can expect the situation to improve with time.
Cheers,
Pete Y.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.