Author: cbrisson Date: Mon Dec 5 14:10:00 2016 New Revision: 1772670 URL: http://svn.apache.org/viewvc?rev=1772670&view=rev Log: [engine] default encoding to UTF-8
Modified: velocity/engine/trunk/src/changes/changes.xml velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeSingleton.java velocity/engine/trunk/velocity-engine-core/src/main/resources/org/apache/velocity/runtime/defaults/velocity.properties Modified: velocity/engine/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/changes/changes.xml?rev=1772670&r1=1772669&r2=1772670&view=diff ============================================================================== --- velocity/engine/trunk/src/changes/changes.xml (original) +++ velocity/engine/trunk/src/changes/changes.xml Mon Dec 5 14:10:00 2016 @@ -28,6 +28,10 @@ <release version="2.0" date="In Subversion"> <action type="add" dev="cbrisson"> + Default encoding is now UTF-8. + </action> + + <action type="add" dev="cbrisson"> Make Velocity use the base logger namespace 'org.apache.velocity' unless specified with runtime.log.name in the configuration, and have the runtime instance log with this base namespace, and other modules log with children namespaces: <ul> <li>directive, and velocity.directive.[directivename]</li> Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java?rev=1772670&r1=1772669&r2=1772670&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeConstants.java Mon Dec 5 14:10:00 2016 @@ -249,7 +249,7 @@ public interface RuntimeConstants /** The character encoding for the templates. Used by the parser in processing the input streams. */ String INPUT_ENCODING = "input.encoding"; - /** Default Encoding is UTF-8 if not found in system. */ + /** Default Encoding is UTF-8. */ String ENCODING_DEFAULT = "UTF-8"; /** key name for uberspector. Multiple classnames can be specified,in which case uberspectors will be chained. */ Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java?rev=1772670&r1=1772669&r2=1772670&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeInstance.java Mon Dec 5 14:10:00 2016 @@ -190,7 +190,7 @@ public class RuntimeInstance implements */ private Map applicationAttributes = null; private Uberspect uberSpect; - private String encoding; + private String defaultEncoding; /* * Space gobbling mode @@ -279,7 +279,7 @@ public class RuntimeInstance implements public synchronized void reset() { this.configuration = new ExtProperties(); - this.encoding = null; + this.defaultEncoding = null; this.evaluateScopeName = "evaluate"; this.eventCartridge = null; this.initialized = false; @@ -457,6 +457,9 @@ public class RuntimeInstance implements configuration.load( inputStream ); + /* populate 'defaultEncoding' member */ + defaultEncoding = getString(INPUT_ENCODING, ENCODING_DEFAULT); + if (log.isDebugEnabled()) { log.debug("Default Properties resource: {}", DEFAULT_RUNTIME_PROPERTIES); @@ -1560,28 +1563,14 @@ public class RuntimeInstance implements */ private String getDefaultEncoding() { - if (encoding == null) - { - /* - * first try to get the OS encoding - */ - encoding = System.getProperty("file.encoding"); - if (encoding == null) - { - /* - * then fall back to default - */ - encoding = getString(INPUT_ENCODING, ENCODING_DEFAULT); - } - } - return encoding; + return defaultEncoding; } /** * Returns a <code>Template</code> from the resource manager. * This method assumes that the character encoding of the * template is set by the <code>input.encoding</code> - * property. The default is platform dependant. + * property. The default is UTF-8. * * @param name The file name of the desired template. * @return The template. Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java?rev=1772670&r1=1772669&r2=1772670&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeServices.java Mon Dec 5 14:10:00 2016 @@ -251,7 +251,7 @@ public interface RuntimeServices * Returns a <code>Template</code> from the resource manager. * This method assumes that the character encoding of the * template is set by the <code>input.encoding</code> - * property. The default is platform dependant. + * property. The default is UTF-8. * * @param name The file name of the desired template. * @return The template. Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeSingleton.java URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeSingleton.java?rev=1772670&r1=1772669&r2=1772670&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeSingleton.java (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/RuntimeSingleton.java Mon Dec 5 14:10:00 2016 @@ -282,7 +282,7 @@ public class RuntimeSingleton implements * Returns a <code>Template</code> from the resource manager. * This method assumes that the character encoding of the * template is set by the <code>input.encoding</code> - * property. The default is platform dependant. + * property. The default is UTF-8. * * @param name The file name of the desired template. * @return The template. Modified: velocity/engine/trunk/velocity-engine-core/src/main/resources/org/apache/velocity/runtime/defaults/velocity.properties URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/resources/org/apache/velocity/runtime/defaults/velocity.properties?rev=1772670&r1=1772669&r2=1772670&view=diff ============================================================================== --- velocity/engine/trunk/velocity-engine-core/src/main/resources/org/apache/velocity/runtime/defaults/velocity.properties (original) +++ velocity/engine/trunk/velocity-engine-core/src/main/resources/org/apache/velocity/runtime/defaults/velocity.properties Mon Dec 5 14:10:00 2016 @@ -25,8 +25,8 @@ runtime.log.invalid.references = true # T E M P L A T E E N C O D I N G # ---------------------------------------------------------------------------- -input.encoding=ISO-8859-1 -output.encoding=ISO-8859-1 +input.encoding=UTF-8 +output.encoding=UTF-8 # ---------------------------------------------------------------------------- # Strings interning