velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mailmur <mail...@yahoo.com>
Subject Re: AW: getEncodingFromStream from UnicodeInputStream
Date Tue, 21 Jul 2009 06:22:14 GMT

I think you misunderstood a fundametal reason of the UnicodeInputStream class. It is to use
so that template loaders don't need to tell an encoding so all is fully transparent.

getTemplate(name, encoding) method is an old legacy method where we as a user must know the
encoding beforehand. This is very very unfortunate issue, something we should not worry about
in the first place.

Its only FileResourceLoader class using the UnicodeInputStream class. All other loaders don't
use it, this is a lack of Velocity loader implementation. If all loaders was to use it then
we just would use getTemplate(name) and all is fine.

FileResourceLoader does not use it as a default use, you must tell "unicode=true" in a velocity.properties
configuration. Then you can forget the file encoding, ansi and utf* templates are loaded properly.

http://svn.apache.org/repos/asf/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/loader/FileResourceLoader.java


--- On Tue, 7/14/09, Johann.Weber@eventim.de <Johann.Weber@eventim.de> wrote:

> From: Johann.Weber@eventim.de <Johann.Weber@eventim.de>
> Subject: AW: getEncodingFromStream from UnicodeInputStream
> To: user@velocity.apache.org
> Date: Tuesday, July 14, 2009, 9:36 AM
> It is in
> org.apache.velocity.app.VelocityEngine.getTemplate(String
> name, String encoding)
> They sure do when you're using BOM in your templates. I
> though it would be nice to use the encoding which was
> determined by UnicodeInputStream.
> 
> -----Urspr√ľngliche Nachricht-----
> Von: mailmur [mailto:mailmur@yahoo.com]
> 
> Gesendet: Montag, 13. Juli 2009 21:16
> An: Velocity Users List
> Betreff: Re: getEncodingFromStream from UnicodeInputStream
> 
> 
> I think its not possible, its basicly an internal
> bytesToChars issue to know about encoding. Textual templates
> know nothing about byte storage they run at character level
> nor know nothing about template loader instance was used.
> 
> What is it getTemplate() method you mean, can you point me
> to the class?
> http://svn.apache.org/repos/asf/velocity/engine/trunk/src/java/org/apache/velocity/
> 
> 
> 
> --- On Wed, 7/8/09, Johann.Weber@eventim.de
> <Johann.Weber@eventim.de>
> wrote:
> > From: Johann.Weber@eventim.de
> <Johann.Weber@eventim.de>
> > Subject: getEncodingFromStream from
> UnicodeInputStream
> > To: user@velocity.apache.org
> > Date: Wednesday, July 8, 2009, 2:48 PM
> > Hi all,
> > 
> > Is there a way to get the encoding information from
> > UnicodeInputStream to use it in the getTemplate()
> method?
> > How do I can use the encoding which was auto detected
> in case of unicode file recognition?


      

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message