Am 2016-12-09 um 16:10 schrieb Claude Brisson:
Hi.
On 09/12/2016 15:34, Michael Osipov wrote:
Hi folks,
the default encoding has been changed recently to UTF-8 [1], though I
still think that it requires some more description from a user's point
of view and more code cleanup
Feel free to help!
* All templates (!) (anything else?) from ImputStream are read with
that new input encoding, unless other stated
That's all, except a resource can also be a static text file, as in
#include('file').
Ah, and I expect input.encoding to be respected here as well?
* Isn't output.econding obsolete? All merge methods require a Writer
anyway.
I removed it at first, and then put it back in because it is used by the
view tools, to set the HTTP response content type charset (as in:
"text/html; charset=UTF-8"). J2EE doc states that this charset will be
used when created the response writer. I know it's a bit of a pity to
have it defined in the engine while it is used in the view tools, but:
- it is how it was done before
- it makes some sense to have it defined here, symmetrically to
input.encoding, even if it's not used directly by the engine
- it's still useful to distinguish input and output encodings, it let
someone serve UTF-8 files from ISO-8859-1 templates, for instance
Are you really certain about this? I just checked the Tools 2.0 code and
VelocityView refers to
public static final String DEFAULT_PROPERTIES_PATH =
"/org/apache/velocity/tools/view/velocity.properties";
which is likely to be an overlay to the default velocity.properties.
Moreover, VelocityView defines UTF-8 already as default, even changed by
you.
I am somewhat confused here. If the Java code of Engine and Tools
contain default encoding UTF-8, why have another duplicate in the
properties file as well?
By defintion of ServletRespose#getWriter() [2] the writer is always
guaranteed to have an encoding set.
Why the (!) ?
To indicate that is solely applies to templates, it doesn't. I simply
forgot about #include.
I am quite certain that Tools need some code cleanup pretty much the
same great cleanup you did to Engine.
Michael
[2]
https://tomcat.apache.org/tomcat-8.5-doc/servletapi/javax/servlet/ServletResponse.html#getWriter()
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org