Hi, I''m sure I''m doing something dumb, but... I have an application that dynamically produces UTF8 encoded html exclusively. This application works using webrick without a problem. When using Mongrel 3.12.4 it looks as though the encoding is lost and garbage appears on the string. I suppose this could also be a double encoding, but personally, I can''t tell the difference by looking :-) Is there something I have to do that''s different when producing UTF8 html in Mongrel? Cheers, Bob ---- Bob Hutchison -- blogs at <http://www.recursive.ca/ hutch/> Recursive Design Inc. -- <http://www.recursive.ca/> Raconteur -- <http://www.raconteur.info/> xampl for Ruby -- <http://rubyforge.org/projects/xampl/>
Hey Bob, Trying out thunderbird so let me know how this message turns out. It claims to have generated my pgp key but looks like that it''s not quite the right one. Anyway, the main problem might be the default encoding setting for default content. Try forcing the response Content-type header to have the proper content type setting. Otherwise I''m not quite sure how you''d even turn on utf8 in ruby? If you can help me get a test case up and running then i''ll try and put that into the mongrel test suite and figure out why it''s not returning the right stuff. Zed Bob Hutchison wrote:> Hi, > > I''m sure I''m doing something dumb, but... > > I have an application that dynamically produces UTF8 encoded html > exclusively. This application works using webrick without a problem. > When using Mongrel 3.12.4 it looks as though the encoding is lost and > garbage appears on the string. I suppose this could also be a double > encoding, but personally, I can''t tell the difference by looking :-) > > Is there something I have to do that''s different when producing UTF8 > html in Mongrel? > > Cheers, > Bob > > ---- > Bob Hutchison -- blogs at <http://www.recursive.ca/ > hutch/> > Recursive Design Inc. -- <http://www.recursive.ca/> > Raconteur -- <http://www.raconteur.info/> > xampl for Ruby -- <http://rubyforge.org/projects/xampl/> > > > > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users > >
Hi Zed, Your message seems to have come through just fine, and it looks as I imagine you intended it to look. I''ve bee playing around with this a bit and tried something this morning, if I add the following: <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> meta tag to the page it works. Simple. For whatever reason, just setting the header content type didn''t work. A couple of comments on this. First, I knew this was necessary from working over the years. I didn''t realise I wasn''t doing it. For some reason, when webrick serves the page without the tag it works, when mongrel serves the page it doesn''t. I''ve found not thinking too hard about unicode the best strategy :-) To use UTF8 all you have to do is set $KCODE to ''u'' and require jcode. See: <http://wiki.rubyonrails.com/rails/pages/HowToUseUnicodeStrings> I''ve had no problems (fewer than in, say, Java -- there is something seriously wrong with the combo of unicode, Java 1.4, and linux) as long as I don''t think about it too much (like I said above). The only oddity is that character count is no longer synonymous with byte count, so sometimes the size method isn''t what you want -- this isn''t too surprising. BTW, Mongrel is working beautifully for me. Nice speedup, and I like the stuff you did w.r.t. administration. It is also kind of cool how you can switch between Mongrel and Webrick with a Control-C and a restart :-) Cheers, Bob On May 8, 2006, at 1:29 AM, Zed Shaw wrote:> Hey Bob, > > Trying out thunderbird so let me know how this message turns out. It > claims to have generated my pgp key but looks like that it''s not quite > the right one. > > Anyway, the main problem might be the default encoding setting for > default content. Try forcing the response Content-type header to have > the proper content type setting. > > Otherwise I''m not quite sure how you''d even turn on utf8 in ruby? If > you can help me get a test case up and running then i''ll try and put > that into the mongrel test suite and figure out why it''s not returning > the right stuff. > > Zed > > Bob Hutchison wrote: >> Hi, >> >> I''m sure I''m doing something dumb, but... >> >> I have an application that dynamically produces UTF8 encoded html >> exclusively. This application works using webrick without a problem. >> When using Mongrel 3.12.4 it looks as though the encoding is lost and >> garbage appears on the string. I suppose this could also be a double >> encoding, but personally, I can''t tell the difference by looking :-) >> >> Is there something I have to do that''s different when producing UTF8 >> html in Mongrel? >> >> Cheers, >> Bob >> >> ---- >> Bob Hutchison -- blogs at <http://www.recursive.ca/ >> hutch/> >> Recursive Design Inc. -- <http://www.recursive.ca/> >> Raconteur -- <http://www.raconteur.info/> >> xampl for Ruby -- <http://rubyforge.org/projects/ >> xampl/> >> >> >> >> _______________________________________________ >> Mongrel-users mailing list >> Mongrel-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/mongrel-users >> >> > > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users---- Bob Hutchison -- blogs at <http://www.recursive.ca/ hutch/> Recursive Design Inc. -- <http://www.recursive.ca/> Raconteur -- <http://www.raconteur.info/> xampl for Ruby -- <http://rubyforge.org/projects/xampl/>
On Mon, 2006-05-08 at 07:57 -0400, Bob Hutchison wrote:> Hi Zed, ><snip>> I''ve bee playing around with this a bit and tried something this > morning, if I add the following: > > <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> > > meta tag to the page it works. Simple. For whatever reason, just > setting the header content type didn''t work. >Ah, by default I think Rails returns just a "text/html" content type. Mongrel doesn''t have anything to do with the content type of the returned stuff unless it doesn''t know the type of a file. Two things you can do: 1) Create a mime.yaml and put an alternative content type in it for text/html. Then tell mongrel to use this configuration file. You could probably steal lots of mime types from apache. 2) Make sure that rails is setting the ; utf-8 ending on all the content you need to be utf-8. I think the first one will actually solve your problem,especially if you have page caching on. <snip>> BTW, Mongrel is working beautifully for me. Nice speedup, and I like > the stuff you did w.r.t. administration. It is also kind of cool how > you can switch between Mongrel and Webrick with a Control-C and a > restart :-)Very nice. Let me know if you run into any more weirdness. -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/