Forum: Ruby on Rails Problem saving data in different languages

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A6085fef3a755acb30996416592d6ecf?d=identicon&s=25 John (Guest)
on 2006-03-10 05:34
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.
A6085fef3a755acb30996416592d6ecf?d=identicon&s=25 John (Guest)
on 2006-03-10 06:44
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.
3dd4b52a0946bd698b1d1635a46ea3a3?d=identicon&s=25 François Beausoleil (fbeausoleil)
on 2006-03-10 07:22
(Received via mailing list)
2006/3/9, John <joaobatista@aol.com>:
> 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/HowToUseUn...

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 !
2f62bd976630967049a829b6e96d07c4?d=identicon&s=25 unknown (Guest)
on 2006-03-10 07:40
(Received via mailing list)
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 Beausoleil <francois.beausoleil@gmail.com>
To: rails@lists.rubyonrails.org
Sent: Thursday, March 9, 2006 10:20:25 PM
Subject: Re: [Rails] Problem saving data in different languages


2006/3/9, John <joaobatista@aol.com>:
> 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/HowToUseUn...

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/
A6085fef3a755acb30996416592d6ecf?d=identicon&s=25 John (Guest)
on 2006-03-10 07:47
Thanks a lot, that worked.



François Beausoleil wrote:
> 2006/3/9, John <joaobatista@aol.com>:
>> 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/HowToUseUn...
>
> 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 !
Be09addcbb47f2a684fa5c48bac94149?d=identicon&s=25 David Johnson (Guest)
on 2006-03-10 13:35
(Received via mailing list)
Use UTF-8 for everything.

I'm a ruby-newbie myself, so the details are still fuzzy.  Perhaps JRuby
is mature enough to try?
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-03-10 21:38
(Received via mailing list)
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.
3cf9b25c40cffcf216bb2cf77f53d8cb?d=identicon&s=25 Edmundo Ruiz (edmundo)
on 2006-03-30 07:00
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!
This topic is locked and can not be replied to.