You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Nick Bauman <ni...@cortexity.com> on 2001/09/08 05:11:09 UTC

Re: Page encoding

> On 9/7/01 12:59 PM, "Nick Bauman" <ni...@cortexity.com> wrote:
> 
>>>  
>>>> Only question remains is how can I detect the encoding of a page
>>>> written in velocity at runtime? I have it hardcoded now for 8859-1.
>>> 
>>> You can't.  It is something that you have to know, just like you have
>>> to know what template you want to render to show a page.
>> 
>> So it's something I have to set on a webapp-level basis with an
>> init-param. Maybe I can figure out how to map certain file extenstions
>> to certain accept-language headers  or something...? I'll rub on it a
>> bit more and report back.
> 
> Yes, it would be something like that - because there is no way for
> velocity to tell automatically what the character representation of
> your bytestreams (files) are...
>> 
>> JSP has this kind of thing set in the page directive (although it
>> never seemed to work in Jasper, but that was a while ago) so you
>> could, according to the spec, set the encoding on a per-page basis.
> 
> Isn't that output encoding?

Well, you'd think that was the case, otherwise they'd have to do strange
things like read the file as unicode to find the encoding header, then
switch encodings and convert the file... 

>>> I think that the majority of people will be using only one encoding.
>>> Maybe we should undeprecate the merge call that assumes the encoding
>>> default?
>> 
>> I have no strong opinion on this one way or the other. I only wish I'd
>> found Velocity sooner. I'm going to be teaching 2 newbies how to write
>> templates for Velocity using my framework this weekend. I taught 1
>> newbie already and he got it in 10 minutes. "It's fun, it's fast, it's
>> furry!" (okay, I have to come up with some other "f" word there...)
> 
> That's great!
> 
> I personally don't mix encodings, and I would be your average site, in
> whatever locale, does the same.   Of course, there are sites that
> support mixing based on user, for example, but I would assume that the
> template encoding is only part of their worries - other things such as
> string resources, date/currency format, idioms, etc matter just as, or
> even more.
> 

I have gotten requests before to make multilingual sites that autodetect the
language preference of the user's browser and serve up appropriately. (We do
it at work with our sites webhelp.fr in Mauritus, webhelp.de in Czeck
Republic and webhelp.com in Montreal using redirects, but its similar)
Apache can do that with static HTML and file extensions (Content
negotiation), but of course doing it with Velocity without some kind of
dynamic detection using file extensions mapped to accept-language headers,
there's no way I can think of to do that. 

> geir
> 
> -- 
> Geir Magnusson Jr.     geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> If you look up, there are no limits - Japanese Proverb

Thanks again.

-- 
Nick Bauman
3600 N. Dupont
Minneapolis, MN 55412
Mobile: (612) 232-7120
Home: (612) 522-0165