Utf-8 support

Folks,

I am trying to use utf-8 Tamil in a Rails application. When I edited
Tamil
unicode contents in a text
box and checked the output. The text got distorted when it is showing it
back.

Any help appreciated

Nandri,
Dalit A.
http://www.tamil.net/
தமிழ் இணையம்
Telford, UK
http://www.erumbugal.com
http://www.mindcolonies.com
http://www.erumbugal.com/Profiles.AmalaSingh

http://del.icio.us/amalasingh/tamilhistory

On Dec 28, 5:39 pm, “Dalit A.” [email protected] wrote:

I am trying to use utf-8 Tamil in a Rails application.

Are you using any plug-ins? I have an application that uses Mandarin
Chinese. It works beautifully with the standard installation of Rails
but when I added the Ferret text search plug-in, I could no longer use
Unicode.

There are many topics covering the proper setup of UTF-8. Try searching
the forums. UTF-8 works fine for me with Japanese.

I’ve had that problem as well.

Adding this as a before_filter to application.rb seems to fix things. It
makes sure that all rhtml files are set to utf8, and spares RJS from
setting
the content-type header so the code still executes.

# Switches to UTF8 charset
#
def configure_charsets
  content_type = @headers["Content-Type"] || 'text/html'
  if /^text\//.match(content_type)
    @headers["Content-Type"] = "#{content_type}; charset=utf-8"
  end
  ActiveRecord::Base.connection.execute 'SET NAMES UTF8'
end

Hope that helps.

On 12/28/06, Dalit A. [email protected] wrote:


http://del.icio.us/amalasingh/tamilhistory

seth at subimage interactive

http://www.subimage.com
http://sublog.subimage.com

http://dev.subimage.com/projects/substruct

Dalit,

There are several things you need to do.

  1. Make sure your database has UTF-8 internationalization set
  2. Check this out: http://wiki.rubyonrails.org/rails/pages/
    InternationalizationComparison.
  3. Use this for rails 1.1

script/plugin install http://svn.globalize-rails.org/svn/globalize/
globalize/ branches/for-1.1.

I apologize for pointing people to my blog and then having it tank.
I’m having some server issues.

Allow me to say that my solution is not as elegant as RaPT but in
case you’re interested, here is my install_plugins.rake (in the lib/
tasks directory)

require ‘yaml’
namespace :plugins do
desc “install a known list of plugins, specified in config/
base_plugins.yml”
task ‘install_base’ do
f = YAML::load_file(File.join(RAILS_ROOT, ‘config’,
‘base_plugins.yml’))
f.each_pair do |plugin, options|
force, svn = ‘’, ‘’
force = ’ --force’ if (options[:force] && options
[:force].downcase == ‘yes’)
svn = ’ -X’ if (options[:svn] && options
[:svn].downcase == ‘yes’)
if force.empty? && File.exist?(File.join(RAILS_ROOT,
“vendor/plugins/#{plugin}”))
puts “Skipping #{plugin} – already installed and
force options not specified.”
else
cmd = “ruby #{RAILS_ROOT}/script/plugin install #
{svn}#{options[‘repos’]} #{plugin}#{force}”
puts “*** installing #{cmd}”
system(cmd)
end
end
end
end

Here is my standard ‘base_plugins.yml’ (in the config directory)

exception_notification:
repos: http://dev.rubyonrails.org/svn/rails/plugins/
exception_notification/
acts_as_authenticated:
repos: http://svn.techno-weenie.net/projects/plugins/
acts_as_authenticated
rspec:
repos: svn://rubyforge.org/var/svn/rspec/tags/REL_0_7_4/vendor/
rspec_on_rails/vendor/plugins/rspec

–steve