Velocity templates seem to fail with UTF-8

Posted by steve on Stack Overflow See other posts from Stack Overflow or by steve
Published on 2011-03-01T07:22:23Z Indexed on 2011/03/01 7:24 UTC
Read the original article Hit count: 171

Filed under:
|
|

Hi,

i have been trying to use a velocity Template with the following content:

Sübjäct $item

everything works fine except the translation of the tow unicode characters. The result string printed on the commandline looks like:

Sübjäct foo

I searched the velocity website and the web an this issue, and came uo with differnt font encoding options, which i added to my code. But those won't help. This is the actuall code:

    velocity.setProperty("file.resource.loader.path", absPath);
    velocity.setProperty("input.encoding", "UTF-8");
    velocity.setProperty("output.encoding", "UTF-8");

    Template t = velocity.getTemplate("subject.vm");
    t.setEncoding("UTF-8");


    StringWriter sw = new StringWriter();

    t.merge(null, sw);       
    System.out.println(sw.getBuffer());

Can anyone give me some hints, how to fix this issue?

© Stack Overflow or respective owner

Related posts about java

Related posts about utf-8