[ 
https://issues.apache.org/jira/browse/VELOCITY-599?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16013168#comment-16013168
 ] 

James R Doyle commented on VELOCITY-599:
----------------------------------------

This bug still exists on trunk and I was able to reproduce it by first fixing 
the unit tests.  
The solution to the problem involves replacing this one linevin 
DataSourceResourceLoader:
               InputStream rawStream = rs.getAsciiStream(templateColumn);
with 
                Reader r = rs.getCharacterStream(templateColumn);
                InputStream rawStream = null;
                try {
                    rawStream = IOUtils.toInputStream(IOUtils.toString(r), 
encoding);
                } catch (IOException ioe) {}

When done, then the test failure goes away.   This was verified on both the 
embedded HSQLDB that is used by the included test suite, as well as against
Oracle 12c.  In both cases, the tests were modified to use a CLOB column rather 
than VARCHAR as in most real world database-stored template scenarious, the 
actual templates would live in CLOB since VARCHAR cols are often limited to 
32KB.

If the first line is is left intact, you can see the outcome of using 
getAsciiStream() on UTF-8 data:
org.junit.ComparisonFailure: Unicode test failed.  

Expected :The Euro Currency Symbol € is a two-byte UTF-8 character.
Actual   :The Euro Currency Symbol ? is a two-byte UTF-8 character.


> DataSourceResourceLoader doesn't support UTF8
> ---------------------------------------------
>
>                 Key: VELOCITY-599
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-599
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.5
>         Environment: WindowsServer2003 R2, 
> Oracle10g(10.2.0,UTF8characterSet),  jdk1.5.0_12
>            Reporter: markchen
>             Fix For: 2.0
>
>
> If templates are stored in the database instead of files,the characters 
> retrived becomes garbled.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org

Reply via email to