UTF-8 problems caching messing stuff up?

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 :frowning:

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. 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

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

Rene P. wrote:


Rails mailing list
[email protected]
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
:wink:

Let’s see if it stays that way…

Thanks you all for the inputs!!
Regards Jonas Montonen, http://bytadvd.se

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
[email protected]
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 :frowning:
// Jonas

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.

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: