Problem saving data in different languages

Hi, I currently have a site that lets people enter info and submit it to
the database. But the problem is the it lets people enter data in their
language (portuguese and spanish) and all the special characters for
those languages get replaced by symbols. Any idea how would I fix that?

Thanks a lot.

This is kinda urgent, please.

Hi, I currently have a site that lets people enter info and submit it to
the database. But the problem is the it lets people enter data in their
language (portuguese and spanish) and all the special characters for
those languages get replaced by symbols. Any idea how would I fix that?

Thanks a lot.

2006/3/9, John [email protected]:

Hi, I currently have a site that lets people enter info and submit it to
the database. But the problem is the it lets people enter data in their
language (portuguese and spanish) and all the special characters for
those languages get replaced by symbols. Any idea how would I fix that?

That partially depends on your database backend and some other things.
Please see the How To Use Unicode Strings on the Rails Wiki:

http://wiki.rubyonrails.org/rails/pages/HowToUseUnicodeStrings

In my case, I use Windows and only have the bit in config/database.yml
and a before_filter set in ApplicationController that sets my
Content-Type to “application/xhtml+xml; charset=UTF-8”. Works fine
for me. YMMV. My physical view files are also UTF-8 encoded. Rails
simply copies bucket-o-bits around, and feels fine with it.

Bye !

Thanks a lot, that worked.

François Beausoleil wrote:

2006/3/9, John [email protected]:

Hi, I currently have a site that lets people enter info and submit it to
the database. But the problem is the it lets people enter data in their
language (portuguese and spanish) and all the special characters for
those languages get replaced by symbols. Any idea how would I fix that?

That partially depends on your database backend and some other things.
Please see the How To Use Unicode Strings on the Rails Wiki:

http://wiki.rubyonrails.org/rails/pages/HowToUseUnicodeStrings

In my case, I use Windows and only have the bit in config/database.yml
and a before_filter set in ApplicationController that sets my
Content-Type to “application/xhtml+xml; charset=UTF-8”. Works fine
for me. YMMV. My physical view files are also UTF-8 encoded. Rails
simply copies bucket-o-bits around, and feels fine with it.

Bye !

A newbie question: I have configured the action mailed properly with
correct smtp server, domain, login, password and port. Yet I cannot the
system cannot sendout the emails, is there a log setting that I can
enable to see the failure logs for ActionMailer? I do see in the
development.log file that a template email that was suppose to be sent
out was printed with working link to confirm the account creation. But
no actual email gets sent out…

I have been trying to get this to work for a while with no luck.

Anu

----- Original Message ----
From: Francois B. [email protected]
To: [email protected]
Sent: Thursday, March 9, 2006 10:20:25 PM
Subject: Re: [Rails] Problem saving data in different languages

2006/3/9, John [email protected]:

Hi, I currently have a site that lets people enter info and submit it to
the database. But the problem is the it lets people enter data in their
language (portuguese and spanish) and all the special characters for
those languages get replaced by symbols. Any idea how would I fix that?

That partially depends on your database backend and some other things.
Please see the How To Use Unicode Strings on the Rails Wiki:

http://wiki.rubyonrails.org/rails/pages/HowToUseUnicodeStrings

In my case, I use Windows and only have the bit in config/database.yml
and a before_filter set in ApplicationController that sets my
Content-Type to “application/xhtml+xml; charset=UTF-8”. Works fine
for me. YMMV. My physical view files are also UTF-8 encoded. Rails
simply copies bucket-o-bits around, and feels fine with it.

Bye !

François Beausoleil
http://blog.teksol.info/

Use UTF-8 for everything.

I’m a ruby-newbie myself, so the details are still fuzzy. Perhaps JRuby
is mature enough to try?

John wrote:

This is kinda urgent, please.

Hi, I currently have a site that lets people enter info and submit it to
the database. But the problem is the it lets people enter data in their
language (portuguese and spanish) and all the special characters for
those languages get replaced by symbols. Any idea how would I fix that?

There’s nothing broken, necessarily. Just make sure that whatever’s
reading the data out of the database speaks the same character set as
the data you’ve got in there, and all should be well, provided that
everything’s in the same character set.

To make sure that your information chain is all using the same character
set, you need to:

  • Set your http headers to the right charset on both standard actions
    and AJAX responses
  • Set the character set in the META head tag.

If you’ve got a running app that’s got to remain collecting live info,
don’t change anything yet until you understand what can be affected by
your changes. The absolute last thing you want is a database with more
than one character set in it.

It works great on my database, as I can save all the spanish characters
like áéíóúüñ, but when I write static text on rhtml pages themseves, I
renders a question mark symbol on the static but the stuff from the
database looks fine. I’ve added a few things, including code like…

< meta http-equiv=“content-type” content=“text/html; charset=utf-8” / >

…and…

class ApplicationController < ActionController::Base
before_filter :set_charset

def set_charset
@headers[“Content-Type”] = “text/html; charset=utf-8”
suppress(ActiveRecord::StatementInvalid) do
ActiveRecord::Base.connection.execute ‘SET NAMES UTF8’
end
end
end

…and…

encoding: utf-8

…on datbase.yml. Some of these did fix the database problems, at
least!