You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Normand Gagnon <ng...@newtradetech.com> on 2002/01/29 21:08:09 UTC

Multiple charset encoding

I'm using velocity-1.2-rc3 and I'm getting a bit confuse with the character 
encoding.  Where should I specify the charset?

In the servlet with:

response.setContentType( "text/html;charset=Shift_JIS" );

or/and

in the html header page with:

<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">

(By the way, are this two lines equivalent?, I mean, do the same thing to 
the page?)

or/and

when I get the template from the VelocityServlet with method:

outty =  getTemplate(responseTemplate,"Shift_JIS");    <---(is this used 
for input encoding or output encoding?)

or/and

in the velocity.properties file with:

#----------------------------------------------------------------------------
# T E M P L A T E  E N C O D I N G
#----------------------------------------------------------------------------

input.encoding=ISO-8859-1
output.encoding=Shift_JIS

...

I say "or/and" because I don't know if I need to use them all.

Using all or a combination of these methods produced these results:

With the response.setContentType() or the html tag <meta> I got Japanese 
characters from a resource bundle property file displayed properly but the 
method japanLocale.getDisplayLanguage(japanLocale) returns three ("???") 
question marks (should be the string "japanese" in japanese language)

Setting the template encoding in the Velocity.properties file makes the 
method japanLocale.getDisplayLanguage(japanLocale) works but the Japanese 
resource bundle does not work anymore ( I got garbage)... Maybe it is 
because my Japanese properties file are not encoding properly, but I'm not 
sure since it works when the template encoding is set to ISO-8859-1...

My main concern is if we have to set the template encoding in the 
velocity.properties file, how do we deal with multiple languages and 
multiple charset? Isn't what the method "outty 
=  getTemplate(responseTemplate,"Shift_JIS"); " was intended for?  I don't 
really know the behavior of this method.

Thank you, and sorry for my poor english :)





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Velocity content-, NOT template caching

Posted by Peter Romianowski <pe...@antaramusic.de>.
Hi there,

I'm using Velocity to create lots of "semi-static" pages.
"semi-static" means that the content (the context, not the 
template - velocity is doing a great job on template-caching)
changes very seldomly.
So I wrote a kind of "cache", that simply stores the output
of a velocity-template along with a key in a hashtable, so
I don't have to build the (very complex) context upon each
call. The result is: speed :)
I know the technique is very simple, nearly everybody
can build up such a thing on her own, and the usability is
quite limited (but I really think, that there are enough
use cases) but I would like to see this within velocity. 
I have further ideas concerning this topic (including 
auto-flush of cached content after a certain amount of time, 
triggered template generation, cache-listeners and things).
Is anyone interested? Of course, I would like to
contribute the code! But first I would like to discuss on
that a bit more.

Any opinions are welcome!

pero


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>