You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Henning Schmiedehausen (JIRA)" <ji...@apache.org> on 2006/08/28 23:49:29 UTC
[jira] Created: (VELOCITY-451) Do some investigation into UTF-16
and InputStream / Reader interfaces
Do some investigation into UTF-16 and InputStream / Reader interfaces
----------------------------------------------------------------------
Key: VELOCITY-451
URL: http://issues.apache.org/jira/browse/VELOCITY-451
Project: Velocity
Issue Type: Improvement
Components: Source
Affects Versions: 2.0
Reporter: Henning Schmiedehausen
Priority: Minor
See http://koti.mbnet.fi/akini/java/unicodereader/ for a description of the problem and some example code.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
[jira] Commented: (VELOCITY-451) Do some investigation into UTF-16
and InputStream / Reader interfaces
Posted by "Mailmur (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/VELOCITY-451?page=comments#action_12449020 ]
Mailmur commented on VELOCITY-451:
----------------------------------
I think we should handle file encoding more transparently than what it is today.
Issue 191, http://issues.apache.org/jira/browse/VELOCITY-191, is using a new UnicodeInputStream which is able to recognize _all_ unicode bom markers. BOM marker tell which bytesToString charset should be used.
So this actually would make "input.encoding" velocity.properties entry obsolete. I have never really liked it, because we might have .vm files using several encodings (ISO-8859-1, UTF-8, UTF-16, ..).
Problem is here and should be studied how to make charset transparent in case of UnicodeInputStream usecase:
src\java\org\apache\velocity\runtime\resource\ContentResource.java
public boolean process() throws ResourceNotFoundException {
BufferedReader reader = null;
try {
StringWriter sw = new StringWriter();
reader = new BufferedReader(
new InputStreamReader(resourceLoader.getResourceStream(name),
encoding));
...clip...
We give here "encoding" value, but actually we _should_ oboye unicode BOM marker. I always say everybody should use unicode file formats, my choice is UTF-8 _with bom marker_ for all text files. Windows Notepad stores files with UTF-8 bom marker, but unfortunately not all text editors do so.
One solution:
Introduce new ResourceLoader interface which returns Reader instance. ResourceLoader could now use own velocity.properties attributes to control what to use in bytesToString translation.
reader = new BufferedReader(resourceLoader.getResourceReader(name));
And velocity.properties could have "defaultCharset" if bom marker is not found. Give ISO-8859-1 or UTF-8 as you please in case of non-bom marked file.
resource.loader = file
file.resource.loader.class = org.apache.velocity.runtime.resource.loader.FileResourceLoader
file.resource.loader.path = ./templates
file.resource.loader.cache = true
file.resource.loader.skipBOM = true
file.resource.loader.defaultCharset=ISO-8859-1
file.resource.loader.modificationCheckInterval = 5
> Do some investigation into UTF-16 and InputStream / Reader interfaces
> ---------------------------------------------------------------------
>
> Key: VELOCITY-451
> URL: http://issues.apache.org/jira/browse/VELOCITY-451
> Project: Velocity
> Issue Type: Improvement
> Components: Engine
> Affects Versions: 2.0
> Reporter: Henning Schmiedehausen
> Priority: Minor
>
> See http://koti.mbnet.fi/akini/java/unicodereader/ for a description of the problem and some example code.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org
[jira] Updated: (VELOCITY-451) Do some investigation into UTF-16
and InputStream / Reader interfaces
Posted by "Henning Schmiedehausen (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/VELOCITY-451?page=all ]
Henning Schmiedehausen updated VELOCITY-451:
--------------------------------------------
Component/s: Engine
(was: Source)
> Do some investigation into UTF-16 and InputStream / Reader interfaces
> ---------------------------------------------------------------------
>
> Key: VELOCITY-451
> URL: http://issues.apache.org/jira/browse/VELOCITY-451
> Project: Velocity
> Issue Type: Improvement
> Components: Engine
> Affects Versions: 2.0
> Reporter: Henning Schmiedehausen
> Priority: Minor
>
> See http://koti.mbnet.fi/akini/java/unicodereader/ for a description of the problem and some example code.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org