Forum: Ruby on Rails UTF-8 problems... caching messing stuff up?

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.
jonte (Guest)
on 2005-11-16 13:27
(Received via mailing list)
Greetings Railers.

I have some problems to get my UTF-8 site to work correctly.
Works fine under webrick and just after the reboot of lighttpd on
production.

But on the next visit to the site, text fetched from the DB containing
��� is replaced på "?"'s :(

Done so far:
*DB (MYSQL) *
  charset set to UTF-8 on all tables.
*
controllers/application.rb*
    before_filter :set_charset
   def set_charset
     @headers["Content-Type"] = "text/html; charset=UTF-8"
   end

  suppress(ActiveRecord::StatementInvalid) do
            ActiveRecord::Base.connection.execute 'SET NAMES UTF8'
  end

Could this be that the caching of the pages are non-utf8??
Solution anyone?

Regards // Jonas Montonen
Andreas S. (Guest)
on 2005-11-16 14:07
jonte wrote:
> Could this be that the caching of the pages are non-utf8??
> Solution anyone?

Appearantly the webserver doesn't sent the correct content-type header.
Try to set it in the HTML source with a meta tag:

<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
jonte (Guest)
on 2005-11-16 14:21
(Received via mailing list)
Andreas S. wrote:
>
>
This does not help... The page is already sent in UTF-8 (Verified in
Firefox, page info)

The problem is that some of the text (not hardcoded into the view) that
are fecthed from the DB are messed up.
Works after a restart of the server... but returns to ???? instead of
Ã?Ã?Ã? after a while.

// Jonas
listbox (Guest)
on 2005-11-16 18:05
(Received via mailing list)
On 16-nov-2005, at 13:19, Jonas Montonen wrote:

> that are fecthed from the DB are messed up.
> Works after a restart of the server... but returns to ???? instead
> of Ã?Ã?Ã? after a while.

You need to call "SET NAMES whatever" on every request.
I recently wrote a little plugin which triggers all the needed hacks
for Unicode for me.
rene (Guest)
on 2005-11-16 19:36
(Received via mailing list)
On Wed, Nov 16, 2005 at 01:07:01PM +0100, Andreas S. wrote:
> jonte wrote:
> > Could this be that the caching of the pages are non-utf8??
> > Solution anyone?


when the cache-files are written, it depends on the output of your
webserver -

e.g. i had to put
--- snip ---
AddDefaultCharset UTF-8
--- snap ---
(beforehand the default output was iso8859-1)
into apache-conf.

greetings

rene
jonte (Guest)
on 2005-11-18 08:11
(Received via mailing list)
Rene P. wrote:
>
>
>
>
>
>
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
I finally managed to locate the default charset option in Webmin (Hosted
at http://www.textdrive.com)
(Apache Server/Virtual Server XYZ/Languages/Character set for
documents*)*.
When I set that one to UTF-8 the caching seems to save my precious Ã?Ã?Ã?'s
;)

Let's see if it stays that way...

Thanks you all for the inputs!!
Regards Jonas Montonen, http://bytadvd.se
jonte (Guest)
on 2005-11-18 14:08
(Received via mailing list)
Jonas Montonen wrote:
>> when the cache-files are written, it depends on the output of your webserver -
>> rene
>>
> Regards Jonas Montonen, http://bytadvd.se
> ------------------------------------------------------------------------
>
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
NOOOOO!!

It's back!!

Well well... back to the drawing board.
Using the plugin as well as UTF-8 as defaullt charset, still no party :(
// Jonas
This topic is locked and can not be replied to.